[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 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
|
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
|