Subject: Re: [xsl] position() from the attribute axis for getting the position of the parent in respect to its siblings From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Thu, 18 Jan 2007 13:56:14 +0100 |
position() is always based on the nodes position within the currently selected node list, not its position within the XML document.
I'm not sure why, but this seems to be a common misunderstanding about position(). position() has _no_ relationship to the position of a node in a source document, it just relates to the position of a node in the current node list (in xslt 1) or the current item in the current sequence (in xslt2).
No, it returns the position in whatever set of nodes you are currently processing. Those might be siblings, or they might not.
I'm not sure what number you want, probably <xsl:number/> or count(preceding-sibling::*)+1
http://www.dpawson.co.uk/xsl/sect2/N6099.html#d8191e311
So to get the result you're after you need to build a node list and then get the position of the node you're after:
<xsl:attribute name="daynr4"> <xsl:variable name="genID" select="generate-id(parent::*)"/> <xsl:for-each select="../../day"> ^^^^^^^^^^^^^^ This builds the node list <xsl:if test="generate-id() = $genID"> <xsl:value-of select="position()"/> </xsl:if> </xsl:for-each> </xsl:attribute>
The above is of course a waste of time, you should just use 1 + count(parent::*/preceding-sibling::*))
Kind regards, -- Abel Braaksma http://www.nuntia.nl
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] position() from the attri, Andrew Welch | Thread | Re: [xsl] position() from the attri, Andrew Welch |
Re: [xsl] Pivot Reports, M. David Peterson | Date | Re: [xsl] position() from the attri, Andrew Welch |
Month |