This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Order of template execution
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 20 Dec 2001 10:28:16 -0000
- Subject: RE: [xsl] Order of template execution
- Reply-to: xsl-list at lists dot mulberrytech dot com
> In an xsl file i have templates in this order
>
> Template 1
> Template 2
> Template 3
>
> 1)Is there any order in which the templates are executed?
> If I change the order will the result change?
No. XSLT template rules follow an event-based processing model. A template
rule says "if X is encountered, do this". The order of processing is
determined by the order of events, not the textual order of the rules.
There's one exception: if you have two template rules that match the same
"event" (i.e. the same node in the source document), it's technically an
error, but the processor can resolve the ambiguity by choosing the rule that
comes last in the stylesheet.
>
> 2)Will the change made by one template affect the source tree?
Nothing done by a stylesheet ever affects the source tree. Templates write
new nodes to the result tree, without changing the source tree.
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list