Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > newbie: how to create a tree structure out of a list of file-path information

Reply
Thread Tools

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

 
 
Daniel Engler
Guest
Posts: n/a
 
      08-25-2003
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 xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput 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">
<xslaram 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hi, I want to implement a General Tree Data structure (Not Binary Tree ) which have more than 2 sub nodes? sharan C Programming 2 10-31-2007 02:58 AM
Hi, I want to implement a General Tree Data structure (Not Binary Tree ) which have more than 2 sub nodes? sharan C Programming 1 10-30-2007 11:01 PM
Hi, I want to implement a General Tree Data structure (Not Binary Tree ) which have more than 2 sub nodes? sharan C Programming 4 10-30-2007 08:21 PM
How to translate a C tree structure to ruby tree objects anne001 Ruby 1 02-18-2006 03:17 PM
B tree, B+ tree and B* tree Stub C Programming 3 11-12-2003 01:51 PM



Advertisments