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

Posted on 2007-10-16
Last Modified: 2013-11-18
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..

Question by:ShaileshShinde
    LVL 60

    Accepted Solution

    that means that there are multiple nodes like this

    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(.,'+',''),',','.')"/>


    LVL 1

    Author Comment

    Thanks Expert!!
    LVL 60

    Expert Comment

    by:Geert Bormans

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
    Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now