[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: position()

Subject: Re: position()
From: David Carlisle <davidc@xxxxxxxxx>
Date: Sun, 16 Apr 2000 18:12:40 +0100 (BST)
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.