Subject: RE: [xsl] What does position() really return From: "Michael Kay" <mhkay@xxxxxxxxxxxx> Date: Fri, 16 Mar 2001 09:50:11 -0000 |
> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] What does position() real, Evan Lenz | Thread | RE: [xsl] What does position() real, Jan Mazac |
RE: [xsl] Comment about XSLT Compli, Ball, Mike | Date | Re: [xsl] Inserting into a String, David Carlisle |
Month |