Subject: Re: [xsl] Efficient XPath 2.0 expression to return each <row> element for which there are other <row> elements having the same navaid? From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 13 Dec 2018 19:02:11 -0000 |
Efficiency depends on the processor, and you're going to need a processor like Saxon-EE that does join optimization. My best attempt in XPath 2.0 is //row[some $q in //row satisfies (./navaid eq $q/navaid and not(. is $q))] but I haven't checked whether it gets suitably optimized. Move to more powerful technology. In XQuery 3.1 you can do for $r in //rows group by $id := navaid where count($r) gt 1 return $r which is almost certain to be implemented efficiently by any self-respecting processor Michael Kay Saxonica > On 13 Dec 2018, at 18:07, Costello, Roger L. costello@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Hi Folks, > > I have a large XML document containing data about airports around the world: > > <airports> > <row> > <navaid>A</navaid> > </row> > <row> > <navaid>B</navaid> > </row> > <row> > <navaid>A</navaid> > </row> > </airports> > > Notice that there is only one <row> element having the B navaid, but two <row> elements having the A navaid. > > I want an XPath 2.0 expression to return each <row> element for which there are other <row> elements having the same navaid. For the above example, I want the XPath expression to return the first and third <row> elements. > > Here is one way to do it: > > //row[navaid = (preceding-sibling::row/navaid, following-sibling::row/navaid)] > > Eek! That is horribly inefficient. I ran that XPath expression on my XML document and it took a long time to finish. > > Is there an efficient XPath 2.0 expression to solve this problem? > > Note: I am running the XPath expression from Oxygen's XPath evaluator, not from an XSLT program. > > /Roger
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Efficient XPath 2.0 expre, Dimitre Novatchev dn | Thread | [xsl] Data extraction, Mailing Lists Mail d |
Re: [xsl] Efficient XPath 2.0 expre, Martin Honnen martin | Date | Re: [xsl] Efficient XPath 2.0 expre, Eliot Kimber ekimber |
Month |