At 2012-04-11 13:29 -0400, Peter Desjardins wrote:
Hi. I am trying to do something in XSLT 2.0 that requires that some of
my templates know what the result of other templates is (or will be).
I want to run a process that writes a file before any other templates
run and then be able to refer to that file during the rest of the
That requires multiple invocations of the processor.
In XSLT 2.0 you can, however, put the results of a template into a
variable and then work with the variable.
If I call a template from the first template like the following, can I
rely on it being completed before any other templates are applied? Is
there a reliable way to perform an operation before any templates are
I'm unclear why you are saying "before". If the template is writing
a file, that file cannot be read subsequently regardless.
But, because your called template is being called before the other
template rules fire, you can be assured that any building of the
result tree is done before.
<xsl:call-template name="this.template.must.be.first" />
You can do the following in order to put the first template into a
structure you can then access later as a parameter:
<xsl:with-param name="myStuff" tunnel="yes">
Then, in your match of any construct you can have:
<xsl:param name="myStuff" tunnel="yes"/>
.... $myStuff/y/z ....
Alternatively, you can simply process the template into a global
variable and then access the global variable. Regardless of how many
times you access the global variable, it will only be evaluated once.
But you cannot, in either XSLT 1.0 or XSLT 2.0, create a result tree
as an output file and then access that output file in the same
invocation of the processor.
I hope this helps.
. . . . . . . . . Ken
Public XSLT, XSL-FO, UBL and code list classes in Europe -- May 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>