[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: Graydon <graydon@xxxxxxxxx>
Date: Sun, 2 Feb 2014 16:50:51 -0500

On Sun, Feb 02, 2014 at 09:04:28PM +0000, Michael Kay scripsit:
> Perhaps you are reading "except" as "that are not", i.e. a negated
> predicate rather than a set difference). In English this reading would
> often work, as in "all vehicles that are not bicycles". But in English
> grammar, what follows "except" is not a predicate that qualifies what
> precedes it: you cannot say "all vehicles except blue". So I think the
> XPath usage is aligned with English usage in this instance.

I've found it useful to read "except" as "without"; I have a sequence,
and what I get is that sequence without the members of this other
sequence which I get to define.

The place I usually get snarled up is remembering that the sequences
are.

* except heading

is easy, that's "all the element children without any heading children", 
(child::*) except (child::heading)

* except (heading, references)

is easy, that's "all the element children without any members of this
thing that's really a sequence which happens to be defined as heading or
reference elements",
(child::*) except (child::heading,child::references)

descendant::* except heading

is really "all the descendant elements without any child heading
elements of the context node", and that's usually a source of
intractable bugs.  I think it should be

descendant::* except self::heading

if I want all the descendant elements without any of the descendant
elements who happen to be heading elements.

But then in XSLT 3.0 (at least as currently available) I can say

<xsl:template match="descendant::* except self::heading">
<!-- something happens -->
</xsl:template>

and I get lost because I have no idea how the first sequence is defined.

-- Graydon


Current Thread
Keywords