Hello there.
In a xslt-stylesheet I'm using the methods exsl:node-set
and set:distinct
to access and filter unique nodes from a variable that contains a result tree fragment.
I can write the values of these nodes into my output file, example:
<xsl:variable name="myNodes">
<xsl:call-template name="getNodes"/>
</xsl:variable>
<xsl:for-each select="set:distinct(exsl:node-set($myNodes)/key)">
<xsl:value-of select="."/>
</xsl:for-each>
The values of the keys are written in the output, just as expected. However, if I try to use the values in an XPath expression, it fails:
<xsl:for-each select="set:distinct(exsl:node-set($myNodes)/key)">
<xsl:variable name="result" select="/tree//somenode[@key = current()]"/>
<xsl:value-of select="$result"/>
</xsl:for-each>
Now, the output is empty, whereas I know that there is a "somenode" in my input-xml that should be selected by the XPath expression and it's value is not empty.
Now my question is: Why does this happen?
I'm using Java 1.6, Xerces 2.7 and Xalan 2.7.
update: as requested, some data for the example: xml doc contains:
<tree>
<somenode key="123"/>
<num>123</num>
<num>0815</num>
</tree>
the getNodes template:
<xsl:template name="getNodes">
<xsl:for-each select="/tree/num">
<xsl:element name="key">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:template>