Help with distinct output

Issues related to W3C XQuery.
tester_123
Posts: 1
Joined: Wed Aug 17, 2016 6:50 pm

Help with distinct output

Post by tester_123 »

Hi,

I've got an xml like the sample below

Code: Select all

<test1>
<test2>
<item1>
<refs>
<value>101</value>
</refs>
</item1>
<item2>
<refs>
<value>101</value>
</refs>
<refs>
<value>102</value>
</refs>
</item2>
<item3>
<refs>
<value>103</value>
</refs>
</item3>
<item4>
<refs>
<value>101</value>
</refs>
</item4>
<item5>
<refs>
<value>101</value>
</refs>
<refs>
<value>102</value>
</refs>
</item5>
<item6>
<refs>
<value>103</value>
</refs>
</item6>
</test2>
<test3>
</test3>
<info1 ref="101">BLUE</info1>
<info2 ref="102">GREEN</info2>
<info3 ref="103">RED</info3>
</test1>
I need an XQuery to return any unique set of info values referenced within each item.

i.e (BLUE | BLUE GREEN | RED)

Any help would be greatly appreciated.

Thanks!
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Help with distinct output

Post by Radu »

Hi,

Probably in the XQuery you can use an XPath 2.0 expression like distinct-values(//*[@ref][@ref=//value[text()]]).

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply