Descending counter in xsl

xml, xslt

Solution

What about as simple as...

<xsl:value-of select="last()-position()+1" />

As fn:last returns the context size, and fn:position - the position of the currently processed item, you just have to substract 1 from their difference (as `position` starts its count from 1, not 0).

Problem

If i use ``` <xsl:value-of select="position()" /> ``` inside a for-each loop in xsl it works great for an ascending counter. Is there any way to change it to a descending counter? Thanks

Original source