- From: Chen Yabing <iscp0054@nus.edu.sg>
- Date: Mon, 18 Feb 2002 20:20:43 +0800
- To: "'www-ql@w3.org'" <www-ql@w3.org>
- Message-ID: <834541D9D742D211A18F0000F81E6921027C272C@exs27.comp.nus.edu.sg>
Hi,
it seems that XQuery cannot place elements together even if they have same
parent elements in the result. I mean that the result will produce two
identical elements for each sub elements.
For example, the source document:
<db>
<project jno="j001">
<supplier sno="s001">
<part pno="p001" >
<price>190</price>
</part>
</supplier>
<supplier sno="s002">
<part pno="p001">
<price>110</price>
</part>
</supplier>
</project>
<project jno="j002">
<supplier sno="s002">
<part pno="p002">
<price>120</price>
</part>
</supplier>
</project>
</db>
the query is:
FOR $j IN document("spj.xml")//project,
$s IN $j/supplier,
$p IN $s/part
WHERE $p/price >100
return
<project jno = {$j/@jno}>
<supplier sno = {$s/@sno}>
<part pno = {$p/@pno}>
{$p/price}
</part>
</supplier>
</project>
and the result is:
<project jno="j001">
<supplier sno="s001">
<part pno="p001">
<price>190</price>
</part>
</supplier>
</project>
<project jno="j001">
<supplier sno="s002">
<part pno="p001">
<price>110</price>
</part>
</supplier>
</project>
<project jno="j002">
<supplier sno="s002">
<part pno="p002">
<price>120</price>
</part>
</supplier>
</project>
</xql:result>
In the ideal situation, the query result should be identical to the source
document. but there are two project whose jno is "j001".
If I want to produce a result which will combine elements under the
identical parent elements together so that there are only one parent
elements. How can I do based on the above query?
Thank you!
Received on Monday, 18 February 2002 07:21:03 UTC