This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: recursion
- To: <xsl-list at mulberrytech dot com>
- Subject: Re: recursion
- From: "Alex Albu" <xsl at mailandnews dot com>
- Date: Wed, 11 Oct 2000 09:54:45 -0400
- Cc: <oscar dot gonzalez at 100world dot es>
- References: <82250F53FC577949BAE058F7183172BA0E8052@W2KMADRID01.100World.es>
- Reply-To: xsl-list at mulberrytech dot com
If your desired output is an XML tree, rather then just printing the id
hierarchy:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes"/>
<xsl:key name="rowstruct" match="row" use="@iParentID"/>
<xsl:template match="/">
<!-- start with the root -->
<xsl:apply-templates select="//row[@iParentID=0]"/>
</xsl:template>
<xsl:template match="row">
<row ItemID="{@ItemID}" szSubject="{@szSubject}">
<xsl:apply-templates select="key('rowstruct', @ItemID)"/>
</row>
</xsl:template>
</xsl:stylesheet>
Hope this helps,
Alex
----- Original Message -----
From: "Oscar Gonzalez" <oscar.gonzalez@100world.es>
To: <xsl-list@mulberrytech.com>
Sent: Wednesday, October 11, 2000 6:32 AM
Subject: recursion
> I have an XML structure like that:
>
> <row ItemID="1" iParentID="0" szSubject="Msg1"/>
>
> <row ItemID="2" iParentID="1" szSubject="Msg2"/>
>
> <row ItemID="3" iParentID="2" szSubject="Msg3"/>
>
> <row ItemID="4" iParentID="1" szSubject="Msg4"/>
>
> <row ItemID="5" iParentID="4" szSubject="Msg4"/>
>
> And I want an XSLT transformation to get this data in a hierarchical tree
> like that:
>
> 1
> 2
> 3
> 4
> 5
>
> Can you help me?
>
> Thanks in advance....
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list