[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: recursion

Subject: RE: recursion
From: Oscar Gonzalez <oscar.gonzalez@xxxxxxxxxxx>
Date: Wed, 11 Oct 2000 17:00:33 +0200
oscar gonzalez
Thanks! It works perfect. Don't believe me, but I haven't found any similar
code in 5 hours of Internet searching... :-)

Thanks very much.

-----Original Message-----
From: Alex Albu [mailto:xsl@xxxxxxxxxxxxxxx]
Sent: miércoles, 11 de octubre de 2000 15:22
To: xsl-list@xxxxxxxxxxxxxxxx; oscar.gonzalez@xxxxxxxxxxx
Subject: Re: recursion


Assuming that the root is identified by iParentID=0 and that in your example
nodes 2 and 4 should be at the same level (since they're both children of
1):

<?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="html" indent="yes"/>

<xsl:key name="rowstruct" match="row" use="@iParentID"/>
<xsl:variable name="nbsp">&#xA0;</xsl:variable>

<xsl:template match="/">
    <!-- start with the root -->
    <xsl:apply-templates select="//row[@iParentID=0]"/>
</xsl:template>

<xsl:template match="row">
    <xsl:param name="indent"/>
    <xsl:value-of select="$indent"/><xsl:value-of select="@ItemID"/><br/>
    <xsl:apply-templates select="key('rowstruct', @ItemID)">
        <xsl:with-param name="indent" select="concat($indent, $nbsp)"/>
    </xsl:apply-templates>
</xsl:template>

</xsl:stylesheet>


Hope this helps,
Alex

----- Original Message -----
From: "Oscar Gonzalez" <oscar.gonzalez@xxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxx>
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


Current Thread
  • recursion
    • Oscar Gonzalez - Wed, 11 Oct 2000 12:32:01 +0200
      • <Possible follow-ups>
      • Oscar Gonzalez - Wed, 11 Oct 2000 17:00:33 +0200 <=
      • Joshua Allen - Wed, 11 Oct 2000 09:03:03 -0700

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.