This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Breadth First Traversal
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] Breadth First Traversal
- From: "Xuegen Jin" <xjin_imi at yahoo dot com>
- Date: Wed, 2 May 2001 22:09:57 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
Try something like this:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:call-template name="traverse">
<xsl:with-param name="list" select="a" />
</xsl:call-template>
</xsl:template>
<xsl:template name="traverse">
<xsl:param name="list" />
<xsl:for-each select="$list">
<!--call "DoSomething" here, comment out the following line-->
<xsl:value-of select="@id" />
</xsl:for-each>
<!--go to next level-->
<xsl:variable name="children" select="$list/a" />
<xsl:if test="$children">
<xsl:call-template name="traverse">
<xsl:with-param name="list" select="$children" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Dan Diebolt
Sent: Wednesday, May 02, 2001 8:52 PM
To: xsl-list@lists.mulberrytech.com
Subject: [xsl] Breadth First Traversal
I need to traverse the attached XML *Breadth* First, at each
a node calling template name="DoSomething". Identified by @id,
the order needed is as follows:
1
1.1 1.2 1.3
1.1.1 1.1.2 1.1.3
1.2.1 1.2.2 1.2.3
1.3.1 1.3.2 1.3.3
1.1.1.1 1.1.1.2 1.1.1.3
1.1.2.1 1.1.2.2 1.1.2.3
1.1.3.1 1.1.3.2 1.1.3.3
1.2.1.1 1.2.1.2 1.2.1.3
1.2.2.1 1.2.2.2 1.2.2.3
1.2.3.1 1.2.3.2 1.2.3.3
1.3.1.1 1.3.1.2 1.3.1.3
1.3.2.1 1.3.2.2 1.3.2.3
1.3.3.1 1.3.3.2 1.3.3.3
Regards,
Dan
-----------------------
<a id="1">
<a id="1.1">
<a id="1.1.1">
<a id="1.1.1.1"/>
<a id="1.1.1.2"/>
<a id="1.1.1.3"/>
</a>
<a id="1.1.2">
<a id="1.1.2.1"/>
<a id="1.1.2.2"/>
<a id="1.1.2.3"/>
</a>
<a id="1.1.3">
<a id="1.1.3.1"/>
<a id="1.1.3.2"/>
<a id="1.1.3.3"/>
</a>
</a>
<a id="1.2">
<a id="1.2.1">
<a id="1.2.1.1"/>
<a id="1.2.1.2"/>
<a id="1.2.1.3"/>
</a>
<a id="1.2.2">
<a id="1.2.2.1"/>
<a id="1.2.2.2"/>
<a id="1.2.2.3"/>
</a>
<a id="1.2.3">
<a id="1.2.3.1"/>
<a id="1.2.3.2"/>
<a id="1.2.3.3"/>
</a>
</a>
<a id="1.3">
<a id="1.3.1">
<a id="1.3.1.1"/>
<a id="1.3.1.2"/>
<a id="1.3.1.3"/>
</a>
<a id="1.3.2">
<a id="1.3.2.1"/>
<a id="1.3.2.2"/>
<a id="1.3.2.3"/>
</a>
<a id="1.3.3">
<a id="1.3.3.1"/>
<a id="1.3.3.2"/>
<a id="1.3.3.3"/>
</a>
</a>
</a>
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list