xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] FW: Recursion over a tree


Subject: [xsl] FW: Recursion over a tree
From: "geoffb" <geoffb@xxxxxxxxxxxxx>
Date: Wed, 10 Apr 2002 16:17:55 -0400

Hi,
I've been messing around in the magical world of XSL recently, and I'm a bit
new, so bear with me.
One thing I need to do is loop over a structure, which can contain any
number of nodes, and any number of levels. The names of the nodes can be
different (very important), so my script needs to be modular.

Take the following structure (purely an example):

<object>
<object>
<object></object>
</object>
<object>
<object>
<object></object>
</object>
</object>
</object>

I need to create a tree type structure based on the above structure:
object
   object
object
   object
      object

So... how? I've got the following code, which is meant to be
recursive. It is a bit hack... I'm missing something here.

<xsl:template match="\">
<xsl:call-template name="recursive-child">
<xsl:with-param name="thisPath"
select="following-sibling::*"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="recursive-child">
<xsl:for-each select="thisPath">
<div align="" style="padding-left:
10px;">
<!-- iterate over children -->
<xsl:value-of select="name
()"/>
</div>
<xsl:call-template name="recursive-
child">
<xsl:with-param
name="thisPath" select="following-sibling::*"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>


Anyway. Any help would be appreaciated!

Geoff B



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords
xsl
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor