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

RE: XSLT 2.0: On xsl:sequence and xsl:copy-of

Subject: RE: XSLT 2.0: On xsl:sequence and xsl:copy-of
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 10 Oct 2003 20:05:35 +0100
xsl sequence
> 
>   O1. The name xsl:sequence is not the best possible name for 
> this xslt instruction.

Yes, we know. But we've failed to come up with anything better. I think
we would go for xsl:value if it were not for the confusion with
xsl:value-of which is not a very good name for an instruction that
produces a text node, but we're stuck with it. 

> Now that everything is a sequence in 
> XPath 2.0, the word sequence has become a buzz word and its 
> overuse (not to say misuse) can only lead to confusion. If 
> the result of this instruction is placing references to nodes 
> in the output, then a more exact name would be one of the
> following:
> 
>     xsl:reference
> 
>     xsl:add-reference
> 
>     xsl:node-reference

None of these are suitable, because xsl:sequence can produce any
sequence of nodes and/or atomic values.
> 
> 
>   O2. xsl:sequence does everything that can be done with 
> xsl:copy-of and these two xslt instructions are mutually redundant.

There is certainly an overlap. With atomic values, they do the same
thing. And it's true that in some contexts, nodes returned be
xsl:sequence are going to get copied anyway, to add them to a new tree.
But returning a node and making a copy of a node are rather different
things.
> 
>   Q1. Is there anything that can be accomplished with 
> xsl:copy-of and which cannot be accomplished by using xsl:sequence?

At this time of a Friday night, I can't immediately recall what the use
case was. Some of the examples we looked at involved validation.
> 
>   Q2. Is there any compelling reason of keeping xsl:copy-of 
> in the language (apart for compatibility with XSLT 1.0)?

See above.
> 
>   Q3. Let's have:
> 
>     <xsl:variable name="v1">
>       <xsl:sequence select="/"/>
>     </xsl:variable>
>     <xsl:variable name="v2">
>       <xsl:sequence select="/"/>
>     </xsl:variable>
> 
>     <xsl:copy-of select="$v1 except $v2"/>
> 
> Should the output of this code be empty or not? If not, what 
> should the output be?

xsl:variable without an "as" attribute constructs a temporary tree, so
in this context xsl:sequence has the same effect as xsl:copy-of. You are
constructing two different trees containing distinct nodes, so ($v1
except $v2) returns $v1.

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.