Hi All,
This is my xml :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<cheesEaters>
<person name="John"/>
<person name="charlie"/>
<person name="Lee"/>
<cheese name="Camembert"/>
<cheese name="Brie"/>
<liking person="John" cheese="Camembert"/>
<liking person="John" cheese="Brie"/>
<liking person="Lee" cheese="Brie"/>
</cheesEaters>
I want to write XQuery which will return only a pair of people based on there similar liking of chees. In the above case it shuld return 'John' and 'Lee'.
Below is my XQuery but I am not getting the desired result, could you please help to get the right result.
XQuery:
Code:
let $doc := doc('CheeseEaters.xml')
for $vper in $doc//person
for $xchz in $doc//cheese
for $plink in $doc//liking
where
$vper/@name = $plink/@person and $xchz/@name=$plink/@cheese
return
<td>
{xs:string ($vper/@name )}
</td>
I am getting the below result:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<td>John</td>
<td>John</td>
<td>Lee</td>
Thanks
-Nelly