How can I remove duplicate nodes in XQuery?
Posted
by Brabster
on Stack Overflow
See other posts from Stack Overflow
or by Brabster
Published on 2009-03-13T20:03:08Z
Indexed on
2010/03/11
5:48 UTC
Read the original article
Hit count: 428
xquery
|duplicates
I have an XML document I generate on the fly, and I need a function to eliminate any duplicate nodes from it.
My function looks like:
declare function local:start2() {
let $data := local:scan_books()
return <books>{$data}</books>
};
Sample output is:
<books>
<book>
<title>XML in 24 hours</title>
<author>Some Guy</author>
</book>
<book>
<title>XML in 24 hours</title>
<author>Some Guy</author>
</book>
</books>
I want just the one entry in my books root tag, and there are other tags, like say pamphlet in there too that need to have duplicates removed. Any ideas?
Updated following comments. By unique nodes, I mean remove multiple occurrences of nodes that have the exact same content and structure.
© Stack Overflow or respective owner