[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Handling Directory Trees

Subject: Handling Directory Trees
From: David_Benua@xxxxxxxxxxxxxx
Date: Wed, 24 Jan 2001 09:06:28 -0500
xsl directory trees handling
We've been searching for an appropriate method to output directory information
as an XML tree.  We have a list of file names (with directory paths) for
example:

<file path="/directory1/directory2/file1" />
<file path="/directory1/directory2/file2" />
<file path="/directory1/directory3/file3" />
<file path="/directory4/directory5/file4" />

and we want an XML tree like this:

<rootnode>
     <directory name="directory1">
          <directory name="directory2">
               <file name="file1"/>
               <file name="file2"/>
          </directory>
          <directory name="directory3">
               <file name="file3" />
          </directory>
     </directory>
     <directory name="directory4">
          <directory name="directory5">
               <file name="file4"/>
          </directory>
     </directory>
</rootnode>

It's pretty easy to parse the file names by recursive descent using
substring-before and substring-after.  This produces a  tree that looks like
this:

<rootnode>
     <directory name="directory1">
          <directory name="directory2">
               <file name="file1" />
          </directory>
     </directory>
     <directory name="directory1">
          <directory name="directory2">
               <file name="file2" />
          </directory>
     </directory>
     etc
</rootnode>

I suppose we could produce the desired output by making a second pass through
this output using following-sibling to find unique directory names. but I'd much
rather do this in one pass.  I'm looking for any suggestions from anybody who
may have encountered this problem before.

We're doing this in a Servlet based system (and using XT).  The data comes from
a relational database, so we can guarantee that the input is in the correct
order.  Any thoughts or suggestions, please let me know

Dave







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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.