Subject: Re: Dependency Sorting, first of kind From: Francis Norton <francis@xxxxxxxxxxx> Date: Tue, 02 Nov 1999 15:50:10 +0000 |
Hi, This might be a first cut - it feels like the right approach but has two problems: First, I've taken the liberty of simplifying the multiple dependencies to single dependencies. I think multiple dependencies should be possible (I assume from the class analogy that they are "and" related) but I would like to normalise them into a "<depends-on dependee='foo' dependent='bar'>" element - would that be acceptable, Paul? Second, and more worrying, I get different results with XT and Saxon, as shown. Can anyone tell me why? Francis. G:\xmlSchema>type t_.xml <?xml version="1.0"?> <data> <a name="jaz" depends-on="bar"/> <a name="spaz"/> <a name="maz" depends-on="spaz"/> <a name="foo"/> <a name="bar" depends-on="foo"/> <a name="baz" depends-on="foo"/> </data> G:\xmlSchema>saxon t_.xml t_.xsl a=spaz a=foo a=maz a=bar a=baz a=jazElapsed time: 641 milliseconds G:\xmlSchema>xt t_.xml t_.xsl <?xml version="1.0" encoding="utf-8"?> a=spaz a=foo a=maz a=bar a=jaz G:\xmlSchema>type t_.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <!-- start by calling untangler with the node-set of roots (ie no dependencies) as a parameter --> <xsl:call-template name="untangler"> <xsl:with-param name="this-set" select="//a/@name[not(../@depends-on)]" /> </xsl:call-template> </xsl:template> <xsl:template name="untangler"> <!-- this single parameter actually contains a (possibly empty) node-set --> <xsl:param name="this-set" /> <!-- here we do something with every node in the parameter node-set --> <xsl:for-each select="$this-set"> a=<xsl:value-of select="." /> </xsl:for-each> <!-- now, if the node-set is not empty, we'll call the template recursively with a new parameter consisting of all the nodes which depended on the ones in *this* node-set --> <xsl:if test="$this-set"> <xsl:call-template name="untangler"> <!-- the [../@depends-on = $this-set] predicate relies on the xpath definition that one node-set "equals" another if there is a single node that is in both sets --> <xsl:with-param name="this-set" select="//a/@name[../@depends-on = $this-set]" /> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Dependency Sorting, first of kind, Paul Prescod | Thread | Re: Dependency Sorting, first of ki, James Clark |
Re: MIF output from XT, sotiris | Date | Re: How can you tell if a variable , Scott Sanders |
Month |