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

Time:07-13

<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

CodePudding user response:

If you run XSLT version="1.0" code (and probably version="1.1" code as well) through an XSLT 2 or 3 processor that supports backwards compatible XPath 1.0 mode then some XPath 1.0 specific rules are applied, mainly that functions receiving sequences/node-sets but expecting a single item use the first item in the node-set/sequence.

In standards mode (XSLT version="2.0" or version="3.0") this is not the case, so you need to make sure that your argument to string-length is a single string and not a sequence of strings.

  • Related