[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: Mon, 12 Apr 2010 18:53:23 +0100
RE:  The output of evaluating an XSLT transform is the
> Is this statement true or false:
> 
>   XSLT elements that produce output can be
>   evaluated in any order.

Well, your terminology is wrong. I guess you are referring to XSLT
instructions; they don't "produce output", they are evaluated to return a
result value.

It's true that if two instructions are independent (neither takes the output
of the other as its input) then they can be evaluated in either order.
> 
> 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.

You have shown two instructions, each of which produces a text node. The
result is two text nodes, not a single string as you have shown. So your
statement is false. However, in many contexts (for example, if the two
xsl:text instructions are children of an xsl:element instruction), the
effect will be the same as if the value were the single string "HelloWorld".
> 
> 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: 
> 

No, this is not the way the semantics are defined. If you write

<xsl:element name="x">
  <xsl:text>Hello</xsl:text>
  <xsl:text>World</xsl:text>
</xsl:element>

Then the semantics are defined in section 5.7.1

http://www.w3.org/TR/xslt20/#constructing-complex-content

which in turn refers to 5.7

http://www.w3.org/TR/xslt20/#dt-sequence-constructor

The two xsl:text instructions form a sequence constructor, which is
evaluated to form a sequence of text nodes; the reason the two instructions
can be evaluated in either order is because there is nothing in the
semantics that changes the result depending on the order of execution.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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