XSLT2 Transformation failed

581 Views Asked by At

I have a problem in a part of a function that gives me the error

XSLT2 Transformation failed: Error in XPath 2.0 expression (Too many items - fn:string)

This is the code line that generates the error:

<xsl:for-each select="(fn:doc($cwklic_codeMappings3)/ns0:KLCodeTable)[(fn:string(ns0:codeType/@name) = 'IFTdep')]">

And this is the entire area of that code.

<xsl:variable name="var93_resultof_map" as="node()?">
    <xsl:for-each select="(fn:doc($cwklic_codeMappings3)/ns0:KLCodeTable)[(fn:string(ns0:codeType/@name) = 'IFTdep')]">
    <xsl:variable name="var92_resultof_first" as="node()" select="ns0:codeType"/>
        <codeType xmlns="http://www.kewill.com/logistics/klic/conversion">
        <xsl:sequence select="($var92_resultof_first/@node(), $var92_resultof_first/node())"/>
    </codeType>
    </xsl:for-each>
</xsl:variable>

And here is a graphical mapping screenshot.

enter image description here

I hope anyone can help me.

1

There are 1 best solutions below

3
On

Presumably this means that a KLCodeTable can have more than one codeType, meaning that the argument to string() contains several attribute nodes.

If you wanted your predicate to evaluate to true if any of the codeTypes had the required value, just drop the call on string(), i.e. write [ns0:codeType/@name = 'IFTdep'].

If you meant something else, then you'd better tell us what you meant...

Incidentally, the fn: prefix is quite unnecessary on function calls in XSLT. By all means use it if your productivity is measured by the length of your code, but otherwise it's a waste of space.