This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: building hierarchy from path string


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]