[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 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) >0"> <xsl:call-template name="bfirst"> <xsl:with-param name="seen" select="$seen|$todo[1]/@version"/> <xsl:with-param name="todo" select="$todo[position() > 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|