This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]