Subject: Re: position() From: David Carlisle <davidc@xxxxxxxxx> Date: Sun, 16 Apr 2000 18:12:40 +0100 (BST) |
> I'm using position() function in two places. Or more particularly, in two current node lists, position() gives the position of the current node in the current node list so you get two different answers. <xsl:for-each select="faq/body/section" > so here you have constructed a list of all sections that are children of body elements which are children of faq elements of the current node. So position() returns the position in that list. <xsl:template match="section" > <xsl:variable name="secno"><xsl:value-of select="position()"/></xsl:variable> Here you didn't show what the node list was. for instance if you go <xsl:apply-templates select="section[3]"/> then you'll construct a node list of length one consisting of the third section child of the current element, so the above template will show a value of position() as 1. If you go <xsl:apply-templates /> in a template matching on the parent of your section element then the above template will fire and this time position() wil be the position in the list selected by default, which includes all elements text, comments, etc. So you don't need to give a template and a for-each example, the same template will give different values for position, depending on the list to which it is applied. David XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: position(), David Carlisle | Thread | Re: position(), G. Ken Holman |
RE: XSL-List admin query, Steven Livingstone | Date | Re: position(), David Carlisle |
Month |