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

Re: [xsl] except

Subject: Re: [xsl] except
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Sun, 02 Feb 2014 23:34:00 +0100

On 02.02.2014 22:50, Graydon wrote:
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.

If you want that and if you insist on using except instead of the classic filtering by predicate,

descendant::*[not(self::heading)] ,

you can easily write:

.//(* except heading) ,

which (partially) expands to

./descendant-or-self::node()/(* except heading) .

I think you'll just have to remember that the sequences on both sides of except will be evaluated from the same context.

This clear but apparently sometimes counterintuitive semantics of except should not change if the expression has some special characteristics. For example, as you suggest, when the expression on the left looks down the descendant axis and the expression on the right, under normal (= mathematically sound) circumstances, would look on the child axis.


Current Thread