Xsl decrease counter
How simple ...
<xsl:value-of select="last()-position()+1" /> As fn: last returns the size of the context and fn: position is the position of the current processed element, you just need to subtract 1 from their difference (since position starts counting from 1, not 0).
You may not need a downstream counter at all (I think this counter is used to index node-set to process it in reverse order) - just use:
<xsl:for-each select="yourNodeSet"> <xsl:sort select="position()" order="descending" data-type="number"/> <!-- Your processing here --> </xsl:for-each>