Subject: Re: topological sort From: David Carlisle <davidc@xxxxxxxxx> Date: Fri, 10 Nov 2000 11:11:32 GMT |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
topological sort, Joerg Pietschmann | Thread | Re: topological sort, Peter B. West |
RE: rendering Xlink from a XML by u, Handren Ahmed | Date | Re[2]: numbering - counting - group, Jeni Tennison |
Month |