|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: position() from the attribute axis for getting the
> for $elem in ../../day return position() > > Or should I read this as the "position of the current element in the > current context, which is the same as current()/position and not the > position that $elem takes in the set of nodes ../../day". No, current() selects a single item, (or is an error if there is no current item) so current()/position() is 1 if it's not an error (which it will be if there is no current item or if it is not a node) on the other hand position() (on its own) returns the current position in the current sequence, compare FLWOR expressions don't change the current item or position() so if you evaluate position() at teh top level of a FLWOR it gives the same value each iteration of teh loop, the value it would have given if evaluated outside the loop. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:variable name="x"> <x>A</x> <x>B</x> <x>C</x> </xsl:variable> <xsl:template name="main"> <xsl:for-each select="$x/*"> ==== <xsl:value-of select="."/> position: <xsl:value-of select="position()"/> current()/position(): <xsl:value-of select="current()/position()"/> for: <xsl:value-of select="for $e in 1 to 3 return position()"/> === </xsl:for-each> </xsl:template> </xsl:stylesheet> $ saxon8 -it main posn.xsl <?xml version="1.0" encoding="UTF-8"?> ==== A position: 1 current()/position(): 1 for: 1 1 1 === ==== B position: 2 current()/position(): 1 for: 2 2 2 === ==== C position: 3 current()/position(): 1 for: 3 3 3 === see, position() gives 1,2,3 current()/position() always gives 1 for $e in 1 to 3 return position() just does position() 3 times. David
|
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
|






