Hi everyone,
I am trying to iterate through a list of nodes in a node-set by index
using the position() function, and I am running into some difficulties.
XML snippet -----
<info>
<field>111</field>
<field>222</field>
</info>
XSLT snippet -----
<!-- $set is the node-set containing the two <field> elements -->
<xsl:for-each select="$set">
<xsl:text>Iteration #</xsl:text>
<xsl:value-of select="position()"/>
<xsl:text> is '</xsl:text>
<xsl:value-of select="$set[position()]"/>
<xsl:text>' </xsl:text>
</xsl:for-each>
This gives the following output
Iteration #1 is 111
Iteration #2 is 111
It seems as though the position() function is working, but when I try to
get at the 2nd node by index, it goes to the first node. If I replace
$set[position()] with $set[2], I get the following...
Iteration #1 is 222
Iteration #2 is 222
So I know that I the second node in the node set is correct, but
position() won't get me to it. Does anyone know how I can fix this
problem? Any help is greatly appreciated.
Thanks,
--Ryan
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list