This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Interpretation of preceding axis (preceding-sibling in particular)
- To: John-Paul Sicotte <jps at messagingDirect dot com>
- Subject: Re: [xsl] Interpretation of preceding axis (preceding-sibling in particular)
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Fri, 3 Aug 2001 18:28:05 +0100
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <EXECMAIL.1010803105931.A@muahost.messagingDirect.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi John-Paul,
> The actual node ordering appears to be correct. Regardless of the
> axis the nodes are returned in document order, only the position
> changes. Is this interpretation correct?
Sort of. Whenever you apply templates to a node set with
xsl:apply-templates to iterate over them with xsl:for-each, they are
processed in document order. The position() function shows you that
numbering.
On the other hand, when you use a predicate in a step, the predicate
treats the nodes selected by the step in the order determined by the
axis used by the step.
So if you do:
<xsl:for-each select="preceding::element">
<xsl:if test="position() = 1">
<xsl:value-of select="." />
</xsl:if>
</xsl:for-each>
then you will get the value of the first 'element' element in the
document (excluding ancestors), but if you do:
<xsl:for-each select="preceding::element[1]">
<xsl:value-of select="." />
</xsl:for-each>
then you will get the value of the 'element' element that occurs
immediately before the one you're currently on.
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list