-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Ryan Sawatzky
Sent: Tuesday, September 23, 2003 8:13 PM
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Accessing node-sets by index with position()
(...)
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 is a strange way of doing this but...
The position() is always refered to the current node set, in this case
$set inside the value-of, so this is the same as get $set that has a
position() :) this is always true. You get 111 because the value-of
always get the first node of a nodeset
Try:
<xsl:for-each select="$set">
<xsl:variable name="pos" select="position()"/>
<xsl:text>Iteration #</xsl:text>
<xsl:value-of select="position()"/>
<xsl:text> is '</xsl:text>
<xsl:value-of select="$set[position()=$pos]"/>
<xsl:text>' </xsl:text>
</xsl:for-each>
Or even better:
<xsl:for-each select="$set">
<xsl:text>Iteration #</xsl:text>
<xsl:value-of select="position()"/>
<xsl:text> is '</xsl:text>
<xsl:value-of select="."/>
<xsl:text>' </xsl:text>
</xsl:for-each>
(...)
Hope this helps
Regards,
Americo Albuquerque
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list