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

Re: most efficient flat file listing to hierarchical

Subject: Re: most efficient flat file listing to hierarchical
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 12 Jan 2007 08:43:14 +0100
Re:  most efficient flat file listing to hierarchical
George Cristian Bina wrote:
Abel,

Your solution does not work correctly, on the sample input it gives:

<dir name="cn"/>
<dir name="cn"/>

Ah, forgot to mention, you are right. I cheated: I first "corrected" the list, but left it out of the solution...


Since it uses following-sibling[1] to check if a file/directory belongs to the same node, it can only work when the list is ordered in a certain way. Analyzing the input, I assumed directory order (like, output of dir, or ls) which is: directory first, then files, then subdirectories. I figured the OP had put the "cn" entry erroneously at the end, so I corrected it like this:

   <item>cn</item>
   <item>cn/test.xml</item>
   <item>en</item>
   <item>en/test.html</item>
   <item>en/test1.html</item>
   <item>en/resource</item>
   <item>en/resource/style</item>
   <item>en/resource/style/test.css</item>
   <item>favicon.ico</item>

In addition, it assumes that a dot in the name is a file, which is not ideal. It were better if a directory is considered a directory when it occurs more than once. Which still does not solve the favicon.ico, which can be either a directory or a file. I choose the latter for ease of implementation.

To make my solution working with any order of input, some adjustments must be made. I tried a few, and I am sure it can be done, but got a bit entangled while trying to keep the solution short and with pure match templates. No doubt I would end above my 12 lines ;-)

-- Abel

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.