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

Re: graph traversal

Subject: Re: graph traversal
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 21 Feb 2000 12:40:35 GMT
graph traversal
simplifying it a bit so your root document is in the same directory
as the others (so getting rid of your 'test/')
the following does I think do a breadth first walk over the graph
omitting nodes already seen.

It could probably be improved (this just doesn't report seen nodes,
it still processes them)

The actual order the nodes are reported is somewhat arbitrary as it
depends how the system orders nodes from different documents.

actually with xt I get

bash-2.01$ xt root.html graph2.xsl 
<?xml version="1.0" encoding="utf-8"?>
6 2 1 3  bash-2.01$ 

> but what I really want is "6 2 1 3".
> (Actually what I really want is "6 2 3 1", but that may be harder.)

so i only get half marks I suppose.




<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:template match="html">
  <xsl:call-template name="bfirst">
    <xsl:with-param name="todo" select="."/>
  </xsl:call-template>
</xsl:template>


<xsl:template name="bfirst">
  <xsl:param name="seen" select="/.."/>
  <xsl:param name="todo"/>
  <xsl:if test="not(string($todo[1]/@version) = $seen)">
  <xsl:value-of select="$todo[1]/@version"/>
  <xsl:text> </xsl:text>
 </xsl:if>
    <xsl:if test="count($todo) &gt;0">
 <xsl:call-template name="bfirst">
    <xsl:with-param name="seen" select="$seen|$todo[1]/@version"/>
    <xsl:with-param name="todo" 
           select="$todo[position() &gt; 1] | 
            document($todo[1]/a/@href)/html"/>
  </xsl:call-template>
  </xsl:if>
</xsl:template>


</xsl:stylesheet>


If that is not right (I only tested it on the one documenent) something
along thse lines could probably be made to work.

David



 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.