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

D

Daniel Engler

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top