this is a german Web-Mirror of MHONARC.ORG powered by Domainunion AG

xsl-list
[Top] [All Lists]

RE: [xsl] Sorting nested steps

2013-07-31 07:53:25
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="https://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>



--~------------------------------------------------------------------
XSL-List info and archive:  https://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: https://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>