Page 1 of 1

Help with distinct output

Posted: Wed Aug 17, 2016 7:34 pm
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!

Re: Help with distinct output

Posted: Thu Aug 18, 2016 3:03 pm
by Radu
Hi,

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

Regards,
Radu