Re: Interpretation of preceding axis (preceding-siblin
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"> <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
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