[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] except (was: Keys with duplicates should be simple)

Subject: Re: [xsl] except (was: Keys with duplicates should be simple)
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxx>
Date: Mon, 3 Feb 2014 10:15:32 -0500


On Sun, Feb 2, 2014 at 10:28 PM, Graydon <graydon@xxxxxxxxx> wrote:
> On Sun, Feb 02, 2014 at 10:48:35PM +0000, Michael Kay scripsit:
>> You've somehow got it into your head that the context for evaluation
>> of the rh operand depends on the lh operand. Like I said, you're
>> thinking of it as a predicate. That's not the case.
> I think what's messing me up here is that (so far as I understand it)
> the default case with a path expression
> /something/foo except bar
> is two sequences-used-to-simulate-node-sets -- (A,B), (B,A), and
> (A,B,B,A) are treated as identical, and they're not identical sequences
> --and both foo and bar are relative to the current context node in the
> path case.
> So if it's div/* except heading
> that comes out to
> (div/child::*) except (div/child::heading)
> and that doesn't register as lh and rh operands being independent.

So now I'm confused by your confusion.

Wouldn't "div/* except heading" be more like "div/child::* except

Whence cometh the 'div' step in the rh operand, as you render it?

Because they are set operators (or are meant to behave as such), it's
true that 'union', 'intersect' and 'except' have that extra semantics
of removing duplicate appearances and reordering sequences of nodes.
This is how (A,B), (B,A) and (A,B,B,A) come to be treated as identical
when using these operators. But nothing about that makes the left-hand
and the right-hand side of the operation any different.

Unlike 'union' and 'intersect', 'except' is not commutative, but
that's because the nodes returned are always from the left-hand side,
not because the two sides are evaluated any differently.

$a except $b

$a[empty(. intersect $b)]

> The good thing about being publicly confused is one subsequently
> remembers, so hopefully the lh and rh independence will stick.


Cheers, Wendell

Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables

Current Thread