[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

XSLT for unflattening a tree?


Subject: XSLT for unflattening a tree?
From: Stuart Hungerford <stuart.hungerford@xxxxxxxxxxxxx>
Date: Fri, 07 Apr 2000 09:48:23 +1000

Hi all,

I've been working with a series of XML documents that effectively represent
"flattened" trees. Instead of using nested elements for each level of the tree,
they use empty header elements that indicate the tree level:

        <h1/>
            <h2/>
                <content .../>
                <h3/>
                    <content .../>
                <h3/>
                    <content .../>
            <h2/>
                  ...
         <h1/>
                 ...

My question is what would be involved in using XSLT to convert that
structure to a nested element structure:

           <h1>
               <h2>
                   <content .../>
                   <h3>
                        <content .../>
                   </h3>
                    <h3>
                          ...
                    </h3>
                ...
               </h2>
            </h1>

In one sense I'd like to maintain a stack of levels, but that's not necessarily
the XSLT "way".  Am I barking up the wrong tree to do this kind of thing
in XSLT?

Cheers,

Stu


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



Current Thread
Keywords