An outline design for XSLT 2.0: write a recursive template that does
<xsl:for-each-group select="$in" group-by="tokenize(.,'/')[$n]">
Initially call this with $in := the sequence of item elements, $n := 1.
On subsequent calls, $in := current-group(), $n := $n+1.
for-each-group does nothing if the population is empty, so the recursion
will terminate naturally.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: James Fuller [mailto:jim(_dot_)fuller(_at_)ruminate(_dot_)co(_dot_)uk]
Sent: 11 January 2007 08:53
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] most efficient flat file listing to hierarchical
Hello All,
Can anyone propose a pure xslt (1 or 2) solution to
transforming the following flat xml structure of directory
paths into a hierarchical
(nested) xml.
<?xml version='1.0'?>
<listing>
<item>cn/test.xml</item>
<item>en</item>
<item>en/test.html</item>
<item>en/test1.html</item>
<item>en/resource</item>
<item>en/resource/style</item>
<item>en/resource/style/test.css</item>
<item>favicon.ico</item>
<item>cn</item>
</listing>
to
<dir>
<file name="favicon.ico"/>
<dir name="cn">
<file name="test.xml"/>
</dir>
<dir name="en">
<file name="test.html"/>
<file name="test1.html"/>
<dir name="resource">
<dir name="style">
<file name="test.css"/>
</dir>
</dir>
</dir>
</dir>
thx in advance.
cheers, Jim Fuller
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--