Subject: RE: [xsl] Accessing node-sets by index with position() From: Americo Albuquerque <melinor@xxxxxxxx> Date: Tue, 23 Sep 2003 23:46:49 +0100 |
> -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Ryan Sawatzky > Sent: Tuesday, September 23, 2003 8:13 PM > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Accessing node-sets by in, Michael Kay | Thread | RE: [xsl] Accessing node-sets by in, Passin, Tom |
Re: [xsl] Adding prefix to elements, G. Ken Holman | Date | Re: [xsl] Adding prefix to elements, Venkat Gyambavantha |
Month |