XML File
<Cities>
<Place>
<City n="New Delhi"></City>
<City n="Chandigarh"></City>
<City n="Mumbai"></City>
</Place>
<Place>
<City n="New Delhi"></City>
<City n="Chandigarh"></City>
</Place>
<Place>
<City n="New Delhi"></City>
<City n="Mumbai"></City>
</Place>
</Cities>
I am using following XQuery -
for $x in doc("sample")/Cities/Place/City
order by $x/@n
return distinct-values($x/@n)
The result I am expecting is -
Chandigarh Mumbai New Delhi
but getting -
Chandigarh Chandigarh Mumbai Mumbai New Delhi New Delhi New Delhi
Please tell me where am I going wrong?