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

Re: Dependency Sorting, first of kind

Subject: Re: Dependency Sorting, first of kind
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Tue, 02 Nov 1999 15:50:10 +0000
francis g. norton
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

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.