|
Subject: [xsl] Handling Directory Trees From: David_Benua@xxxxxxxxxxxxxx Date: Wed, 24 Jan 2001 09:06:28 -0500 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] XPath number with 20 digi, Michael Kay | Thread | RE: [xsl] Handling Directory Trees, Michael Kay |
| Re: [xsl] Copying unknown attribute, David Carlisle | Date | RE: [xsl] New nntp news group for x, DPawson |
| Month |