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

Re: topological sort

Subject: Re: topological sort
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 10 Nov 2000 11:11:32 GMT
xsl topological sort
ho hum, does this do the right thing? It uses a node list rather than a
string to maintain state information.

The linking implied by ref isn't implemenetd very efficiently
it would be more efficient if it was done with an attribute of type ID
(in which case you could use id() ) or with keys.

It produces ACBED on your test file.

David

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

<xsl:output method="text"/>
  
<xsl:template match="structs">
 <xsl:apply-templates select="struct[1]"/>
</xsl:template>


<xsl:template match="struct">
 <xsl:param name="done" select="x[false()]"/>
 <xsl:choose>
 <xsl:when test="../struct[name=current()/field/type/ref and not(name=$done)][1] ">
  <xsl:apply-templates select="../struct[name=current()/field/type/ref and not(name=$done)][1]">
   <xsl:with-param name="done" select="$done"/>
  </xsl:apply-templates>
 </xsl:when>
 <xsl:when test="not(name=$done)">
  <xsl:value-of select="name"/>
  <xsl:apply-templates select="../struct[not(name=$done)][1]">
   <xsl:with-param name="done" select="$done|name"/>
  </xsl:apply-templates>
  </xsl:when>
  <xsl:otherwise>
  <xsl:apply-templates select="../struct[not(name=$done)][1]">
   <xsl:with-param name="done" select="$done"/>
  </xsl:apply-templates>
  </xsl:otherwise>
 </xsl:choose>

</xsl:template>



</xsl:stylesheet>

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp


 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.