This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: for-each order
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Charly" <cohana at investacorp dot com>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 14 Dec 2001 17:12:43 +0000
- Subject: Re: [xsl] for-each order
- Organization: Jeni Tennison Consulting Ltd
- References: <00d201c184d6$78980120$c4c909c0@COHANA>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Charly,
> Is there a way to do <xsl:for-each ..... and looping backwards.
Sure. Sort (numerically) on position() in descending order:
<xsl:for-each select="histo/bar">
<xsl:sort select="position()" order="descending"
data-type="number" />
<xsl:value-of select="@value" />
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
Note that the call to position() in the select attribute of the
xsl:sort looks at the order of the selected nodes in the document,
whereas the call to position() within the xsl:for-each looks at the
sorted order of the nodes as they're being processed.
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list