Subject: RE: [xsl] Breadth First Traversal From: "Xuegen Jin" <xjin_imi@xxxxxxxxx> Date: Wed, 2 May 2001 22:09:57 -0400 |
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: [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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Breadth First Traversal, Dan Diebolt | Thread | RE: [xsl] Breadth First Traversal, Dan Diebolt |
[xsl] Here is my MSXML sscripting Q, Walter Torres | Date | RE: [xsl] Breadth First Traversal, Dan Diebolt |
Month |