I have a recursive template so that I can update a count. In the template, I want to be able to use the current count to be able to access the node whose index is the current count.
<!-- in the template -->
<xsl:param name="i"/>
<xsl:param name="count"/>
<NewNode>
<xsl:value-of select="//ACommonElementInTheDocument[$i]/MyElement"/> : <xsl:value-of select="$i"/>
</NewNode>
I get $i printed out correctly, as expected, but I’m not able to reference the element, although this works perfectly when I use XMLSpy to test the XPath.
Could anyone point out the glaring mistake I’m making please?…
Many thanks
I’m not sure how you have declared the parameter. But my guess is that this is a type casting problem. What happens if you try:
Or in XSLT 2.0 you could also use one of the XML Schema types: