Subject: Re: [xsl] things about grouping From: Graydon <graydon@xxxxxxxxx> Date: Thu, 29 Nov 2012 05:12:03 -0500 |
On Thu, Nov 29, 2012 at 05:58:45AM +0000, Ihe Onwuka scripsit: > > Since we're talking about "except" and language definitions, has anyone > > ever proposed a different form (or is there a different form for) the > > construct: > > > > div[not(* except (heading,para))] > > > > It's really useful, but I find it frequently brain-melting, especially > > as a component of more complex expressions. > > A problem here is the mixture of notation from mathematical (set > theoretic in the form of except) and non-mathematical (the comma > operator). [snip] > Now (get ready for the leap of faith and giant hand wave), substitute > the comma operator back for the | and you have div[(heading,para] All the divs who have heading or para children, yes, but that's not quite the same thing. Unless I'm unusually addled this morning, div[not(* except (heading,para))] is a div which has _only_ heading or para children just as div[* except (heading,para)] is a div with some other element child than heading and para So for the trivial markup <bucket> <div> <heading>Word</heading> </div> <div> <heading>Word</heading> <para>Words</para> </div> <div> <heading>Word</heading> <para>Words</para> <para>Words</para> <figure>Picture</figure> </div> <div> <heading>Word</heading> <figure>Picture</figure> </div> </bucket> //div[(heading,para)] selects all the divs, /bucket/div[1], /bucket/div[2], /bucket/div[3], and /bucket/div[4] //div[not(* except (heading,para))] selects /bucket/div[1] and /bucket/div[2] //div[* except (heading,para)] selects /bucket/div[3] and /bucket/div[4] I can imagine a //div[only(heading,para)] //div[not(only(heading,para))] syntax instead, which I would find much less head-melty, but am not sure it has a suitable mathematical justification. (Or would be of sufficiently general interest to bother the XPath spec committee about.) -- Graydon
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] things about grouping, Ihe Onwuka | Thread | Re: [xsl] things about grouping, Ihe Onwuka |
Re: [xsl] things about grouping, Ihe Onwuka | Date | Re: [xsl] things about grouping, David Carlisle |
Month |