xsl-list
[Top] [All Lists]

Re: [xsl] The output of evaluating an XSLT transform is the same regardless of the order in which output elements are evaluated. Right?

2010-04-15 21:35:03
On Mon, Apr 12, 2010 at 10:37 AM, Costello, Roger L. 
<costello(_at_)mitre(_dot_)org> wrote:
Hi Folks,

Is this statement true or false:

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

Notice the last sentence in the quoted text from the XSLT 1.0 Specification;
http://www.w3.org/TR/xslt#for-each

"<!-- Category: instruction -->
<xsl:for-each
  select = node-set-expression>
  <!-- Content: (xsl:sort*, template) -->
</xsl:for-each>

When the result has a known regular structure, it is useful to be able
to specify directly the template for selected nodes. The xsl:for-each
instruction contains a template, which is instantiated for each node
selected by the expression specified by the select attribute. The
select attribute is required. The expression must evaluate to a
node-set. The template is instantiated with the selected node as the
current node, and with a list of all of the selected nodes as the
current node list. 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. We could argue that
such restriction isn't necessary, but this doesn't change the text of
the Spec. I only wonder if an official test case exists to test
conformance to the required order of processing (and could this be
verified at all?).


The XSLT 2.0 Specification is very careful not to define any
processing order for <xsl:for-each/>

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."


I personaly find that these texts contradict what we would like a
functional language to be: as independent of any processing order as
possible.



Example: This XSLT produces two outputs:

  <xsl:text>Hello</xsl:text>
  <xsl:text>World</xsl:text>

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:

  <xsl:text>World</xsl:text>

occurs later in the XSLT document and so therefore it is placed later in the 
result tree. After the XSLT transform completes executing then the result 
tree is serialized to an output file, in document order, which result in 
"Hello" first and "World" second.

/Roger


--~------------------------------------------------------------------
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>
--~--





-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
I enjoy the massacre of ads. This sentence will slaughter ads without
a messy bloodbath.

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>