Re: [xsl] building hierarchy from path string

Subject: Re: [xsl] building hierarchy from path string
From: "John-Mason P. Shackelford" <john-mason@xxxxxxxxxxxxxxx>
Date: Wed, 05 Dec 2001 16:50:51 -0600
Jenni & others,

Sorry to clutter up the list...

The corrected template follows.

Thanks again for all your help!

John-Mason
--
http://john-mason.shackelford.org

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text/xml" indent="yes" />
<xsl:variable name="tierChars" select="tree/descriptor/@chars-per-tier"/>
<xsl:key name="children" match="node" use="substring(@path, 1, @depth * $tierChars)" />


<xsl:template match="tree">
<tree>
<xsl:apply-templates select="key('children','')" />
</tree>
</xsl:template>
<xsl:template match="node">
<node name="{@name}">
<xsl:apply-templates select="key('children', substring(@path,1,(@depth + 1) * $tierChars))">
<xsl:sort select="@path" />
</xsl:apply-templates>
</node>
</xsl:template>
</xsl:stylesheet>



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread