The functx library has a bunch of functions to do stuff like this.  I think 
distinct-deep works for this.  You can find those here:

http://www.xqueryfunctions.com/

And also MarkLogic ships with that library, so you can import it directly.

Here is an example:


  xquery version "1.0-ml";

  import module namespace fx = "http://www.functx.com";
      at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";

let $x := <tests>
<test>
<id>1</id>
<desc>xx</desc>
</test>
<test>
<id>2</id>
<desc>yy</desc>
</test>
<test>
<id>1</id>
<desc>xx</desc>
</test>
</tests>
return fx:distinct-deep($x/node())
=>
<test>
  <id>1</id>
  <desc>xx</desc>
</test>
<test>
  <id>2</id>
  <desc>yy</desc>
</test>

From: [email protected] 
[mailto:[email protected]] On Behalf Of Abhishek53 S
Sent: Wednesday, March 06, 2013 2:58 PM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] List of Unique Nodes

Hi Folks,

Can someone please help me in getting list of unique nodes from below XML


<tests>

<test>

<id>1</id>

<desc>xx</desc>

</test>

<test>

<id>2</id>

<desc>yy</desc>

</test>

<test>

<id>1</id>

<desc>xx</desc>

</test>

</tests>
I need the output like


<tests>

<test>

<id>1</id>

<desc>xx</desc>

</test>

<test>

<id>2</id>

<desc>yy</desc>

</test>

</tests>

Thanks in advance!!
Abhishek Srivastav
Tata Consultancy Services
Cell:- +91-9883389968
Mailto: [email protected]<mailto:[email protected]>
Website: http://www.tcs.com<http://www.tcs.com/>
____________________________________________
Experience certainty. IT Services
Business Solutions
Outsourcing
____________________________________________


=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to