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

Re: [xsl] Tree from directory listing


Subject: Re: [xsl] Tree from directory listing
From: Geert Josten <Geert.Josten@xxxxxxxxxxx>
Date: Thu, 16 Dec 2004 09:36:44 +0100

Hi Mukul, (and others,)

Ah, it does process deeper directories, apart from a minor bug (you are passing @path in the named templates instead of $path).

Though, the result doesn't look like what I would have expected. It only merged folders and subfolders properly when the files are sorted in advance, so it seems..

Generalizing on the original question, I feeded your stylesheet the following XML and had to fix the case where the $path contains less than 2 slashes to prevent (another) endless loop:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <file name ="f5.xyz" path="/test2/folderInFolder3/folderInFolder4/"/>
  <file name ="f1a.xyz" path="/"/>
  <file name ="f1.xyz" path="/test/"/>
  <file name ="f4b.xyz" path="/test/folderInFolder2/"/>
  <file name ="f3.xyz" path="/test/folderInFolder/"/>
  <file name ="f2.xyz" path="/test/folderInFolder/"/>
  <file name ="f4.xyz" path="/test/folderInFolder2/"/>
  <file name ="f5b.xyz" path="/test2/folderInFolder3/"/>
</root>

(I deliberately mixed the order)

I was also wondering what would happen if the input doesn't supply a file for each subfolder that should be output. For example just:

  <file name ="f1a.xyz" path="/"/>
  <file name ="f4b.xyz" path="/test/folderInFolder2/"/>

The result was getting a bit awkward by this time, so I tried to work out the following approach:
build a folder structure for each file separately and merge it in a second step.

Less efficient maybe, but it seems to do its job quite well..

If anyone is interested, I'll share the stylesheet...

Cheers,
Geert

The XSL works on folder structure any deep..

Regards,
Mukul

--- Geert Josten <Geert.Josten@xxxxxxxxxxx> wrote:


Hi,

Ah! It took a second look to notice that the xsl:key
is being applied to the contents of the RTF variable as well... :)


Does it work on a three level deep folder structure
as well?

Cheers

Mukul Gandhi wrote:


Below is a XSLT 1.0 solution. I have used the

node-set


extension function..





__________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com





-- Geert.Josten@xxxxxxxxxxx IT-consultant at Daidalos BV, Zoetermeer (NL)

http://www.daidalos.nl/
tel:+31-(0)79-3316961
fax:+31-(0)79-3316464

GPG: 1024D/12DEBB50


Current Thread
Keywords