Re: Efficient Stylesheets for reordering

Subject: Re: Efficient Stylesheets for reordering
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 8 Nov 2000 10:44:24 +0000

> Am I completely wrong on my understanding of XSLT?

Almost ;) The big gap seems to be that you think that the XSLT
processor is working on a stream of information that comes into it
from the XML, and is writing out a stream of information concurrently.
This is inaccurate.

What actually happens is that the XSLT processor parses the XML
document and creates from it a tree representation of the document
(the Document Object Model or DOM).  It stores this DOM in memory and
operates over it to create another DOM (the result).  Then it
(usually) serialises this DOM into an output file.

One of the points about XSLT is that processors don't *have* to do all
the processing sequentially: there is nothing in the language that
prevents them from applying templates to s1 nodes, s2 nodes, s3 nodes
and so on, all concurrently, and then constructing the result from
that directly.

Some processors allow asynchronous and partial transformation.  You
could have a look at MSXSL (XSLProcessor) and Saxon (saxon:preview)
which may be helpful.

In your case, where you're just copying nodes across from one tree
into a different structure, you can use xsl:copy-of rather than

<xsl:template match="doc1" >
  <xsl:copy-of select="s1[1]" />
  <xsl:copy-of select="s3" />
  <xsl:copy-of select="s4[1]" />
  <xsl:copy-of select="s2[1]" />
  <xsl:copy-of select="s5" />

I'm not sure whether the position predicates will make much
difference, but they certainly won't hurt unless you change your DTD.

I hope that helps somewhat,


Jeni Tennison

 XSL-List info and archive:

Current Thread