Here is the most general way to do "reverse recursion" , which is independent of this particular problem and can be used in a variety of problems.
This conversion is :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:call-template name="backwardsRecursion">
<xsl:with-param name="pList" select="//person"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="backwardsRecursion">
<xsl:param name="pList"/>
<xsl:if test="$pList">
<xsl:apply-templates select="$pList[last()]"/>
<xsl:call-template name="backwardsRecursion">
<xsl:with-param name="pList" select=
"$pList[position() < last()]"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="person">
<xsl:value-of select="concat(@name,'
')"/>
</xsl:template>
</xsl:stylesheet>
when applied to the original XML document, it produces the desired result :
Shemp
Curly
Moe
Larry
, "backwardsRecursion", . , , , .
, , .