- From: Jonathan Robie <jonathan.robie@datadirect-technologies.com>
- Date: Fri, 14 Mar 2003 11:00:41 -0500
- To: "Chen Yabing" <iscp0054@nus.edu.sg>, <www-ql@w3.org>
At 04:36 PM 3/14/2003 +0800, Chen Yabing wrote: >I want to have such a result by executing an XQuery: ><db> > <d dno="d1"> > <b bno="b1"/> > <b bno="b2"/> > </d> > <d dno="d2"> > <b bno="b2"/> > </d> ></db> > >the result means that for each distinct d, we need all b with distinct bno >that appear under their (d & b) common ancestor a. >for example, for d1, a's ano can be "a1" & "a2", then all b with distinct >bno under "a1" and "a2" are "b1" and "b2" >for d2, only "b2". If I have understood your text correctly, here is one solution: let $b := distinct-values($in//b/@bno) return <d dno="{$d}"> { for $bno in $b where some $a in $in//a satisfies ( exists($a//b[@bno=$bno]) and exists($a//d[@dno=$d]) ) return <b bno="{$bno}"/> } </d> I imagine more elegant solutions could be written. I haven't given this a lot of time. Jonathan
Received on Friday, 14 March 2003 11:01:09 UTC