[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
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
|