[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: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 16 Apr 2010 09:30:51 +0100
RE:  The output of evaluating an XSLT transform is the
> The nodes are processed in 
> document order, unless a sorting specification is present 
> (see [10 Sorting])."
> So, in XSLT 1.0 there is order of processing (at least in the case of
> <xsl:for-each/>) and it is explicitly specified.

XSLT 1.0 often used rather informal language like this; XSLT 2.0 took great
pains to avoid unwanted implications suggested by this kind of language.
That's probably why XSLT 1.0 was written in a year, while XSLT 2.0 took
seven years.

There is no way in XSLT 1.0 of telling what the actual order of evaluation
is, and therefore a statement in the spec that suggests a particular order
has no force. Processors are conformant if they produce the right results in
all circumstances, whether or not they do things the way the spec suggests
they should be done.

I'm sure the intent of the XSLT 1.0 spec was to say that xsl:for-each
defines a function F (its template body) that maps nodes in the input
sequence I to nodes in the output sequence O, and the result of the
xsl:for-each instruction is O = map(F, sort(I)) where sort is a function
that sorts a set of nodes into a sequence of nodes in document order.

> However, I don't know what the following text from the XSLT 
> 2.0 Specification means (does it mean that in many cases 
> there is still prescribed order of processing?):
> http://www.w3.org/TR/xslt20/#for-each
> "Note:
> With XSLT 1.0, the selected nodes were processed in document order.
> With XSLT 2.0, XPath expressions that would have been valid 
> under XPath 1.0 (such as path expressions and union 
> expressions) will return a sequence of nodes that is already 
> in document order, so backwards compatibility is maintained."

The note is trying to explain how the apparently different specifications
for 1.0 and 2.0 actually deliver the same result. Notes are informal and
intended to aid understanding; if you don't find them useful, you can ignore

In this particular case the burden of sorting nodes into document order fell
on XSLT in the 1.0 specification, but falls on XPath in the 2.0 spec.


Michael Kay

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.