Tony,

You might consider a hashmap for this: http://marklogic.markmail.org/search/?q=map:put has a couple of examples. Neither are exactly your use-case, but they'll give you sample code to start from.

You'll have to decide how to turn the selective bits of each 'if' element into a map key: one simplistic approach would use xdmp:quote() on the entire element. You'll also have to decide whether you'd like the map to include the first or the last match for each key (it may not matter to you, in which case you can choose whichever is easier to implement).

-- Mike

On 2009-10-09 04:14, Tony Mariella wrote:
If I have results that look like this:
<item>
     <if>
        <name>Test</name>
        <date>01-Oct-2009</date>
        <id>ID 1</id>
        <address>2345</address>
     </if>
     <if>
        <name>Test</name>
        <date>01-Oct-2009</date>
        <id>ID 2</id>
        <address>3456</address>
     </if>
     <if>
        <name>Test</name>
        <date>01-Oct-2009</date>
        <id>ID 1</id>
        <address>2345</address>
     </if>
     <if>
        <name>Test</name>
        <date>01-Oct-2009</date>
        <id>ID 2</id>
        <address>3456</address>
     </if>
</item>

And I want to de-dupe the results so that I get this:
<item>
     <if>
        <name>Test</name>
        <date>01-Oct-2009</date>
        <id>ID 1</id>
        <address>2345</address>
     </if>
     <if>
        <name>Test</name>
        <date>01-Oct-2009</date>
        <id>ID 2</id>
        <address>3456</address>
     </if>
</item>

How would I do it ?

Tony Mariella
Raytheon Company



_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to