|
Subject: Re: [xsl] Sorting nested steps From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 31 Jul 2013 08:38:32 -0400 |
I have a series of nested steps that I want to reverse sort at each level. Here is what I am starting with: ... This is what I want to get: ... 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.
T:\ftemp>type rick.xml
<?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>
T:\ftemp>xslt rick.xml rick.xsl
<?xml version="1.0" encoding="utf-8"?>
<steps>
<step>C</step>
<step>B</step>
<step>A
<step>(3)</step>
<step>(2)
<step>(c)</step>
<step>(b)</step>
<step>(a)</step>
</step>
<step>(1)</step>
</step>
</steps>
T:\ftemp>type rick.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><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> T:\ftemp>
-- Public XSLT, XSL-FO, and UBL classes in the Netherlands Oct 2013 | Public XSLT, XSL-FO, UBL and code list classes in Australia Oct 2013 | Contact us for world-wide XML consulting and instructor-led training | Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm | Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ | G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx | Google+ profile: https://plus.google.com/116832879756988317389/about | Legal business disclaimers: http://www.CraneSoftwrights.com/legal |
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Sorting nested steps, Rick Quatro | Thread | RE: [xsl] Sorting nested steps, Rick Quatro |
| [xsl] Sorting nested steps, Rick Quatro | Date | RE: [xsl] Sorting nested steps, Rick Quatro |
| Month |