[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Sorting nested steps
Hi, I have a series of nested steps that I want to reverse sort at each level. Here is what I am starting with: <?xml version="1.0"?> <steps> <step>A <step>(1)</step> <step>(2) <step>(a)</step> <step>(b)</step> <step>(c)</step> </step> <step>(3)</step> </step> <step>B</step> <step>C</step> </steps> This is what I want to get: <?xml version="1.0"?> <steps> <step>C</step> <step>B</step> <step>A <step>(3)</step> <step>(2) <step>(c)</step> <step>(b)</step> <step>(a)</step> <step>(1)</step> </step> </step> </steps> My steps could be nested up to five levels, so I tried to call a template recursively, but it is not giving me exactly what I want. Here is my stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/steps"> <xsl:call-template name="sort-steps"/> </xsl:template> <xsl:template name="sort-steps"> <xsl:for-each select="step"> <xsl:sort order="descending"/> <xsl:copy><xsl:value-of select="."/></xsl:copy> <xsl:call-template name="sort-steps"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> Thank you in advance. Rick
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|