|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: position()
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








