[xquery-talk] xquery distinct-values

Jane Doe becauseur at hotmail.com
Mon Apr 10 00:02:48 PDT 2006

First, please accept my apologies if this is the wrong place to post.

I have two xml files.

file1.xml has

file2.xml has
<car id='1'>
<car id='3'>
<car id='4'>

I am trying to write an xquery that will return the names with more than 2 
of any style:

for $x in doc("file1.xml")/namelist/person
let $y := doc("file2.xml")/carlist/car[@id=$x/carids]
for $value in ($y/style)
where count($y/style[.=$value]) ge 2
order by ($x/name) descending
return <name>{data($x/name)}</name>

This returns the names of everyone with more than 2 of any style, but it 
returns that same name multiple times (in relation to the number of 
duplicate styles).

I hope it's not too confusing, and I appreciate any help you can give me.


Express yourself instantly with MSN Messenger! Download today - it's FREE! 

More information about the talk mailing list