Subject: Re: [xsl] Interpretation of preceding axis (preceding-sibling in particular) From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Fri, 3 Aug 2001 18:28:05 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Interpretation of precedi, Michael Kay | Thread | RE: [xsl] Interpretation of precedi, Oleg Tkachenko |
Re: [xsl] change a list of attribut, Jeni Tennison | Date | [xsl] using "and" / "or", Carlos Pisquem |
Month |