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

Re[2]: Efficient Stylesheets for reordering

Subject: Re[2]: Efficient Stylesheets for reordering
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 9 Nov 2000 10:47:10 +0000
Re[2]: Efficient Stylesheets for reordering
Jose,

> Jeni, I understand the semantic model defined by XSLT, which is what you
> describe here. But as far as I understand, it is up to the implementations
> to process the tree in some order, top-down in parallel, bottom-up, using a
> DFS algorithm or whatever. 

I can't speak to implementations, but there are other people on the
list who can and I'm sure will address your questions about processing
optimisations.  As you point out, it is possible to write XSLT that
takes advantage of the optimisations that the processors use, if you
know about them, but all too often you don't.

> <xsl:template match="s5[????]" > <!-- Some way to say position larger than 1
-->>

You can use:

  position() > 1

However, it is more efficient (at least for most processors, I think)
to put predicates like this within the xsl:apply-templates select than
within the xsl:template match because it narrows down the tedious
search for templates as early as possible in the process.

> I do not think it is possible to use s2var the way I am doing, 
> but you can see that this set of templates can be easily process
> in an streamming fashion. The only memory needed is that to store
> the subtree "s2".

You're right that it isn't possible to use s2var in that way. In fact,
to get the benefit that you're after, you need to have one template
that holds the flow of the processing explicitly:

<xsl:template match="doc1">
  <doc2>
    <xsl:apply-templates select="s1" />
    <xsl:variable name="s2var" select="s2" />
    <xsl:apply-templates select="s3" />
    <xsl:apply-templates select="s4" />
    <xsl:apply-templates select="$s2var" />
    <xsl:apply-templates select="s5" />
  </doc2>
</xsl:template>

I think that a streaming XSLT processor would require you to declare
any out-of-order references (i.e. XPaths that select nodes that don't
follow the previously-selected node) as variables at the point where
the nodes are encountered. These variables would have to be passed as
parameters into the templates that use them later on. For most
non-trivial transformations, handling all this would be a very tedious
task for the author.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.