newbie: how to create a tree structure out of a list of file-path information

Discussion in 'XML' started by Daniel Engler, Aug 25, 2003.

  1. Hello
    I'd like to create a tree-structure out of a tag <archive-path>
    contained in several files. Let me explain the problem in detail:

    I have a lot of XML-Files like

    <?xml version="1.0" encoding="iso-8859-1"?>
    <resource type="test1">
    <description></description>
    <name>Knoop-Oesterlin.1925</name>
    <creator>University of Bern</creator>
    <archive-creation-date></archive-creation-date>
    <archive-path>ubern/urea</archive-path>
    <content-type></content-type>
    <meta></meta>
    </resource>

    I have a file metadata.xml that points to each of thes files.

    <?xml version="1.0" encoding="iso-8859-1"?>
    <meta_files>
    <file>/path/ubern/astro/Mq_2/index.meta</file>
    <file>/path/ubern/astro/Fu_1/index.meta</file>
    <file>/path/ubern/urea/Salaskin-Kriwsky.1931/index.meta</file>
    <file>/path/ubern/urea/Salaskin-Solowjew.1930/index.meta</file>
    <file>/path/ubern/toc/deimel_1929/index.meta</file>
    <file>/path/ubern/rom/00000571-428-r-full.meta</file>
    </meta_files>


    I'd like to create a tree using the information in the tags
    <archive-path> and <name>

    It's easy to create a list of the content from <archive-path> and
    <name>
    like that:

    rom/00000272-asl-160-r-full.tif
    toc/deimel_1929
    ubern/astro/fu_1
    ubern/astro/mq_2
    ubern/urea/Abderhalden.1903
    ubern/urea/Abderhalden-Buadze.1926

    I can create this list using the template below.

    but I don't know how to create at tree like

    <ul>
    <li>rom
    <ul>
    <li>00000272-asl-160-r-full.tif</li>
    </ul>
    </li>
    <li>toc
    <ul>
    <li>deimel_1929</li>
    </ul>
    </li>
    <li>ubern
    <ul>
    <li>astro
    <ul>
    <li>fu_1</li>
    <li>mq_2</li>
    </ul>
    </li>
    <li>urea
    <ul>
    <li>Abderhalden.1903</li>
    <li>Abderhalden-Buadze.1926</li>
    </ul>
    </li>
    </ul>
    </li>
    </ul>



    -------------template to create a list of path info-----------------

    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:eek:utput method="text" />
    <xsl:template match="/">
    <xsl:call-template name="rec_each_archivePath">
    <xsl:with-param name="liste"
    select="document(/meta_files/file)/resource" />
    </xsl:call-template>
    </xsl:template>

    <xsl:template name="rec_each_archivePath">
    <xsl:param name="liste" />
    <xsl:for-each select="$liste" >
    <xsl:sort order="ascending" select="./archive-path"/>
    <xsl:sort order="ascending" select="./name"/>
    <xsl:variable name="strArchivePath" select="./archive-path" />
    <xsl:variable name="strName" select="./name" />
    <xsl:value-of select="$strArchivePath"/>/<xsl:value-of
    select="$strName" /><xsl:text>
    </xsl:text>
    </xsl:for-each>
    </xsl:template>

    </xsl:stylesheet>

    Thank you very much
    Daniel
     
    Daniel Engler, Aug 25, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,132
  2. sharan
    Replies:
    4
    Views:
    693
    CBFalconer
    Oct 30, 2007
  3. sharan
    Replies:
    2
    Views:
    835
    SM Ryan
    Oct 31, 2007
  4. sharan
    Replies:
    1
    Views:
    693
    CBFalconer
    Oct 30, 2007
  5. anne001
    Replies:
    1
    Views:
    238
Loading...

Share This Page