xsl-list
[Top] [All Lists]

Nested Disk tree layout

2002-12-03 05:30:59
Helo, I've currently got a filesystem analysis program which produces XML
output eg.
<ALL>
  <TITLE> .... </TITLE>
  <BYDIRECTORY>
   <L0>
     <PATH="some path">
     <SIZE="disk used">
     <L1>
        <PATH="subdirectory">
         <SIZE="disk used">
          <L2>
              .... more stuff down to L7 ...
          </L2>
     </L1>
  </L0>
  </BYDIRECTORY>
  <BYCUSTOMER>
   ...stuff I don't care about at the moment..
  </BYCUSTOMER
</ALL>

The L0 L1 etc. nests down up to 8 levels. I've gotten as far as modifying a
'TOC' template off microsoft's website to process
this into a useful output:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version
="1.0">
<xsl:output method="html"/>
<xsl:template match="text()"/>

<xsl:template match="/">
  <html>
    <body>
      <H3>Table of Contents</H3>
      <xsl:apply-templates select="ALL/BYDIRECTORY" mode="toc"/>
    </body>
  </html>
</xsl:template>

<xsl:template match="L0|L1|L2|L3|L4|L5|L6|L7" mode="toc">
  <DIV STYLE="margin-left:2em">
    <xsl:call-template name="format_table">
      <xsl:with-param name="count">
       <xsl:number count="L1|L2|L3|L4|L5|L6|L7" />
      </xsl:with-param>
    </xsl:call-template>

    <xsl:value-of select="DIR"/>
    <xsl:if test="not ( string-length(@DIR) = 0 )">
        &#160; = <xsl:value-of select="SIZE"/> <br/>
    </xsl:if>
    <xsl:apply-templates select="L1|L2|L3|L4|L5|L6|L7" mode="toc"/>
  </DIV>
</xsl:template>
</xsl:stylesheet>

This produces a rather neatly indented layout, which was _almost_ what I
was trying to re-create.
The problem is, that ideally I'd also like to be able to format it into an
HTML table, looking something like this:

/fs001      <total usage>
      /subdir1    <usage of subdir1>
            /another sub      <usage of that other sub>
      /subdir2    <usage in subdir2>

apologies if that formatting doesn't come out right, but basically, because
the data are recursive, the 'L0' nodes are total usage
for the subnodes, and I'd like to lay it out in such a way that makes it
easy to read - which basically means getting the child elements to
column format. My actual aim here, is to get the 'sizes' aligned, based on
recursion depth.

It've tried putting '<TABLE>' directives around the xsl:apply-templates but
this doesn't seem to work. (I haven't figured out why
yet, but there must be a reason). Can anyone offer suggestions? I'd rather
avoid having to make an XSL loop that inserts a load of &nbsp;s
to be able to format it, but my limited experimentation with styles doesn't
seem to give me the desired results.

Is there a nicer template to use, that doesn't require brute force layouts
of the L0 ... L8? (The script which generates this output has
a recursion depth, so in theory this might increase).

Or am I simply going about this the wrong way? Some pointers to
alternatives would be good.


Cheers.
Ed Rolison




CONFIDENTIALITY:
This e-mail and any attachments are confidential and may be privileged. If
you are not a named recipient, please notify the sender immediately and do
not disclose the contents to another person, use it for any purpose, or
store or copy the information in any medium.


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



<Prev in Thread] Current Thread [Next in Thread>