RE: [xsl] Sorting nested steps

Subject: RE: [xsl] Sorting nested steps
From: "Rick Quatro" <rick@xxxxxxxxxxxxxx>
Date: Wed, 31 Jul 2013 08:53:17 -0400
Hi Ken,

Thank you very much for the code. It looks like the recursion is "built-in"
with the apply-templates rule inside the match. Also, I didn't' think of the
position() function, which will help me get the correct sort. Thanks again
for the quick response.

Rick



When I think of recursion, I try to think of how applying templates would
work ... and the end result is really quite compact.

I hope the code below helps.

. . . . . . . Ken

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   version="1.0">

<xsl:output indent="yes"/>

<xsl:template match="steps | step">
   <xsl:copy>
     <xsl:apply-templates select="text()[normalize-space()]"/>
     <xsl:apply-templates select="step">
       <xsl:sort select="position()" order="descending"/>
     </xsl:apply-templates>
   </xsl:copy>
</xsl:template>

</xsl:stylesheet>

Current Thread