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

Re: The output of evaluating an XSLT transform is the

Subject: Re: The output of evaluating an XSLT transform is the same regardless of the order in which output elements are evaluated. Right?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Apr 2010 13:54:59 -0400
Re:  The output of evaluating an XSLT transform is the
At 2010-04-12 13:37 -0400, Costello, Roger L. wrote:
Is this statement true or false:

  XSLT elements that produce output can be
  evaluated in any order.

"elements that produce output" is ambiguous. There are literal result elements and there are instruction elements. Both can be building the output. I think your statement needs to focus not on the elements but on the stylesheet as a whole.

An entire stylesheet can be processed internally in any way so long as the end result is predictable where the specification prescribes it. An instruction may despatch a number of nodes for processing and the end results are assembled in despatching order not completion order. But within the processing of one of those despatched nodes, there may be the despatching of other nodes, and those nested ones need to be assembled in that despatched order before the end result is assembled in the order the set was despatched.

This is consistent with the nested nature of XML and the processing of XML.

And even my use of "despatching" implies that the processor is visiting the stylesheet nodes in order. It only has to act as if it had visited the nodes in the stylesheet in order.

Example: This XSLT produces two outputs:


Is this statement true or false:

   The output will always be "HelloWorld" regardless
   of which <xsl:text> element is evaluated first.


Is this explanation correct:

Explanation: the outputs produced by each XSLT element is placed in an in-memory "result tree." Their position in the result tree depends on the sequential order of the outputs in the XSLT document. Thus, this XSLT element:


occurs later in the XSLT document and so therefore it is placed later in the result tree.

"later in the document?" No ... it is encountered after the earlier one is encountered. The order of template rules is arbitrary in XSLT so location in the XSLT document is not useful to your answer. Consider:

  <xsl:call-template name="do-hello"/>
  <xsl:call-template name="do-world"/>
  <xsl:template name="do-world">
  <xsl:template name="do-hello">

The order of the two <xsl:text> instructions isn't helpful. The order in which they are encountered is significant. That is the "despatch order" I'm referring to.

After the XSLT transform completes executing then the result tree is serialized to an output file,

How the processor does it is irrelevant. One processor may do it that way. All processors do it as if it were done that way. But the use of "in-memory" and "result tree" constructs or whatever is up to the processor.

in document order,

"in the order despatched for processing" (which might not be document order).

which result in "Hello" first and "World" second.

Always for your example, for all processors, but regardless of the innards.

How is the answer to this important to your work with XML and XSLT? The innards of the processor don't impact on the end result.

I hope this helps.

. . . . . . . . . . Ken

XSLT/XQuery training:         San Carlos, California 2010-04-26/30
Principles of XSLT for XQuery Writers: San Francisco,CA 2010-05-03
XSLT/XQuery training:                 Ottawa, Canada 2010-05-10/14
XSLT/XQuery/UBL/Code List training: Trondheim,Norway 2010-06-02/11
Vote for your XML training:   http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread


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.
First Name
Last Name
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.