• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1597
  • Last Modified:

XPTY0004: A sequence of more than one item is not allowed as the first argument of translate()

Hello Expert,

I am getting following error for the code below...

<xsl:value-of select="translate(translate(prolog/asMetadata/apiVersion/apiPlatform/@version,'+',''),',','.')"/>
with the error as

XPTY0004: A sequence of more than one item is not allowed as the first argument of translate()

can you please suggest what will be the alternative for the line code in saxon xslt2.0..

Thanks,
Shailesh
0
ShaileshShinde
Asked:
ShaileshShinde
  • 2
1 Solution
 
Geert BormansCommented:
that means that there are multiple nodes like this
prolog/asMetadata/apiVersion/apiPlatform/@version

XSLT2 makes it a sequence
and you can't use translate on a sequence of nodes
If you need the first one only, you can do something like this
<xsl:value-of select="translate(translate(prolog[1]/asMetadata[1]/apiVersion[1]/apiPlatform[1]/@version,'+',''),',','.')"/>

or you can string-join() them to be sure
<xsl:value-of select="translate(translate(string-join(prolog/asMetadata/apiVersion/apiPlatform/@version, ''),'+',''),',','.')"/>

or loop over the values
<xsl:for-each select="prolog/asMetadata/apiVersion/apiPlatform/@version">
     <xsl:value-of select="translate(translate(.,'+',''),',','.')"/>
</xsl:for-each>

cheers

Geert
0
 
ShaileshShindeAuthor Commented:
Thanks Expert!!
0
 
Geert BormansCommented:
welcome
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now