[SOLVED] <xsl:when test="string-length( xpath value) is not working after xslt version upgrade to xslt 3.0 version

Issue

<xsl:when test="string-length( xpath value) is not working after xslt version upgrade to xslt 3.0 version>

it is giving error

XPTY0004 A sequence of more than one item is not allowed as the first argument of
fn:string-length() ("", " ")

but it was working correctly with 1.1 version

Solution

In XSLT 1.0, if you called a function such as string-length() supplying a set of multiple nodes in the argument, it ignored all nodes except the first.

This led to so many bugs that the rule was changed in 2.0, so supplying more than one node is an error. If you want the first node rule, change string-length(PATH) to string-length((PATH)[1]). (You can also leave the stylesheet version set to 1.0 to get backwards compatibility mode.)

Answered By – Michael Kay

Answer Checked By – Cary Denson (BugsFixing Admin)

Leave a Reply

Your email address will not be published.