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

RE: Breadth First Traversal

Subject: RE: Breadth First Traversal
From: "Xuegen Jin" <xjin_imi@xxxxxxxxx>
Date: Wed, 2 May 2001 22:09:57 -0400
breadth first traverse
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@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Dan Diebolt
Sent: Wednesday, May 02, 2001 8:52 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  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


Current Thread

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.