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

Re: Things that make you go Hmmmm!

Subject: Re: Things that make you go Hmmmm!
From: "Abel Braaksma (Exselt)" <abel@xxxxxxxxxx>
Date: Sat, 29 Mar 2014 16:40:04 +0100
Re:  Things that make you go Hmmmm!
On 29-3-2014 16:11, Michael Sokolov wrote:
> On 3/29/2014 10:43 AM, Abel Braaksma (Exselt) wrote:
>>
>> While a tempting idea, it wouldn't work in practice I think, even if,
>> for a moment, we ignore backward compatibility issues. Consider the
>> identity template, the deepest copy always ends up with an empty
>> selection in the xsl:apply-templates. This is effectively the same as an
>> empty sequence constructor. Your proposal would mean that:
>>
>> <xsl:copy />
>>
>> and
>>
>> <xsl:copy>
>>     <xsl:apply-templates select="()" />
>> </xsl:copy>
>>
>> would both behave differently, depending on the context node. The first
>> would copy the whole subtree without further processing, the second,
>> which also has an effectively empty sequence constructor, would only
>> copy the current node without its children.
> I don't think I understand this.  Are you saying that <xsl:template
> match="@*|node()"> matches the empty sequence? That would be quite
> surprising to me.  I can see that <xsl:apply-templates /> on an empty
> node could cause an attempt to match an empty sequence, but does that
> actually fire rules?

No, not directly. I meant to say that in the modified identity template
example that I gave, the processor will recursively go through all
nodes, and eventually will reach an attribute (in which case "@*|node()"
will select nothing) or a leaf node like text() or
processing-instruction() (in which case it will also select nothing).
The result of those deepest iterations is that there is nothing to copy
anymore and xsl:copy will do nothing.

My point was that it might lead to surprises if such a statement that
does not select anything, is used directly. Hence my select="()". In the
event where we were to allow your proposal of having xsl:copy also
behave as xsl:coy-of, I think this case will lead to problems in
practice, because you effectively say "when xsl:copy has no sequence
constructor, copy everything, when it has an empty sequence constructor
or one that selects an empty node set, copy nothing".

> Yeah, I think that priniciple is over-stressed - as I said in an
> earlier post, I think judicious suprises can be an essential spur to
> learning, but I recognize this is a matter of taste.

True, and no language in existence will ever give the same surprises
everywhere and to everyone. People come to a language with different
backgrounds and different use-cases, leading to different learning
curves. and hence different surprises. It is up to the language
designers to try to make them as few as possible, but there always comes
a time when someone thinks there are too many of those surprises, or in
the wrong spots of the language. Which in turn, keeps us sharp ;).

Cheers,

Abel Braaksma
Exselt XSLT 3.0 processor
http://exselt.net

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.