Let's say I have the following XML:
<info>
<channel>
<A>
<X>
<title>title1</title>
</X>
<Y value="20"/>
</A>
</channel>
<channel>
<A>
<X>
<title>title1</title>
</X>
<Y value="20"/>
</A>
<A>
<X>
<title>title2</title>
</X>
<Y value="20"/>
</A>
</channel>
</info>
and the following XQuery
{
for $A in doc('test.xml')//A
let $TITLE := $A/X/title
where string($A/Y/value) > 20
return
string($TITLE)
}
this, of course, outputs:
title1
title1
title2
How can I use distinct-values
in order to remove duplicates? I wonder because for
essentially only gives me one item per iteration and I can't call distinct-values
on $A
. Or is there any other way to remove duplicate output?
The problem is that I need to refer to another node, so basically calling distinct-values(doc...)
doesn't work, as it doesn't return nodes.