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

RE: What does position() really return

Subject: RE: What does position() really return
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Fri, 16 Mar 2001 09:50:11 -0000
RE:  What does position() really return
> I'm trying to find out, what the position() function really returns.

When used as an XPath expression in its own right, it returns the position
of the current node within the current node list, which is the list of nodes
selected by the innermost xsl:for-each or xsl:apply-templates.

> <xsl:template match="Personen">
> 	<xsl:apply-templates/>
> </xsl:template>

This one selects all child nodes of Personen, including whitespace text
nodes. Generally the whitespace text nodes will be odd-numbered, the element
children will be even numbered.
>
> Changing the "Personen" template to:
>
> <xsl:template match="Personen">
> 	<xsl:apply-templates>
> 	<xsl:sort select="."/>
> 	</xsl:apply-templates>
> </xsl:template>
>
> generates (result 2):
>
> Output: 6, Danny
> Output: 7, George
> Output: 8, Jan
> Output: 9, Peter

This is because the whitespace text nodes are now sorted before the
elements.
>
> and once more changing "Personen" to:
>
> <xsl:template match="Personen">
> 	<xsl:apply-templates select="Person">
> 	<xsl:sort select="."/>
> 	</xsl:apply-templates>
> </xsl:template>
>
> results in (result 3):
>
> Output: 1, Danny
> Output: 2, George
> Output: 3, Jan
> Output: 4, Peter
>
This time you didn't select the whitespace text nodes, you only selected the
elements.

Mike Kay
Software AG


 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.