Difficult to tell without seeing your full code:
(a) if you have a very large number of templates of the form
i.e. all matching the same element name, but with different
predicates, then deciding which template to invoke will involve a
serial search. By contrast, if you use <xsl:choose> with a
similar list of conditions, then Saxon-EE will optimize this using a
(b) if you use saxon:discard-document() and then subsequently read
the same document again, it will be read and parsed again. You
should only use this function if you don't expect the document to be
used more than once (and if you need the reclaim the memory). Using
the -t option should tell you what documents are being read/parsed.
Basically, with performance issues the devil is in the detail. You
therefore need to supply full information: e.g. two different ways
of writing the same stylesheet, a representative source document,
and timings for both versions of the code.
On 23/06/2012 11:38, David Rudel wrote:
I'm wondering if I'm doing something wrong because when I use
"<xsl:apply-templates>" rather than "<xsl:for-each>" I
see a major performance hit (e.g. a 40 second operation becoming
I'm wondering if it has something to do with the requirement to
pass variables into the new template? In particular, variables
that represent document nodes that are flagged with
For example, suppose I have a template that processes a roster of
employees. For each employee the template pulls up a record of the
tasks the employee has done, where each task is a node:
To process these tasks, data from a separate document is required.
This separate document is the same for each task but is specific
to the employee (so it doesn't make sense for that document to be
a global variable).
I may need to process several different kinds of task nodes for
each employee, so I need to pass this individual record to each of
several templates. There may be many, many different nodes that
need processing, so the same record is being passed dozens of
times to other templates:
I would think that XSL processors would do everything possible to
make this sort of operation not significantly more CPU-intensive
than a completely pull-processing model where no variables need to
be passed anywhere.
Is it normal to take such a performance hit using push processing?
I've tried various other options, like simply passing the URI to
the document rather than the entire document node or having the
original variable be a normal document and passing the
saxon:discard-document version of it. These approaches nearly
tripled the run-time, though.
I'm assuming that tunnel variables will not help anything here
because the templates I am calling do not call further templates,
but perhaps my understanding of tunnel variables is incomplete.
"A false conclusion, once arrived at and widely accepted is not
dislodged easily, and the less it is understood, the more
tenaciously it is held." - Cantor's Law of Preservation of
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
saxon-help mailing list archived at http://saxon.markmail.org/