- From: Chen Yabing <iscp0054@nus.edu.sg>
- Date: Fri, 14 Mar 2003 16:36:20 +0800
- To: <www-ql@w3.org>
assume the xml file is: <db> <a ano="a1"> <b bno="b1"/> <b bno="b2"/> <c cno="c1"> <d dno="d1"/> </c> </a> <a ano="a2"> <b bno="b2"/> <c cno="c1"> <d dno="d1"/> </c> <c cno="c2"> <d dno=d2"/> </c> </a> </db> 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". I think one XQuery may be like this: for $dno in distinct(document("a.xml")//d/@dno) return <d dno="$dno"> { let $a := document("a.xml")//a[descendant::d/@dno=$dno] for $bno in distinct(document("a.xml")//b[ ancestor::a/@ano in ($a/@ano) ]/@bno) return <b bno="$bno"/> } </c> can XQuery currently support the set comparison operator, such as "ancestor::a/@ano in ($a/@ano)"? or can I use some other way to implement such a comparison? otherwise, can XQuery support such a result?
Received on Friday, 14 March 2003 03:34:53 UTC