I would construct the new node first and then use xdmp:document-insert(uri,newnode) to overwrite. This way there is only one update.
--Matthew From: [email protected] [mailto:[email protected]] On Behalf Of Nachiketa Kulkarni Sent: Thursday, December 12, 2013 8:34 AM To: [email protected] Subject: [MarkLogic Dev General] deleteing duplicate elements from XMLs in Marklogic Hi, I have an xml in the below form: <a> <b> <c href="input1"/> <c href="input2"/> <c href="input1"/> <c href="input1"/> <c href="input1"/> <c href="input3"/> <c href="input3"/> <c href="input1"/> <c href="input1"/> <c href="input1"/> </b> <b> <c href="input1"/> <c href="input2"/> <c href="input1"/> <c href="input1"/> <c href="input1"/> </b> </a> I want to retain the <c> elements with unique @href. The duplicate entries should be removed. Thus, the output should be: <a> <b> <c href="input1"/> <c href="input2"/> <c href="input3"/> </b> <b> <c href="input1"/> <c href="input2"/> </b> </a> I have written the below xquery for the same: declare namespace functx = "http://www.functx.com"; declare function functx:is-node-in-sequence ( $var2ode as node()? , $seq as node()* ) as xs:boolean { some $var2odeInSeq in $seq satisfies $var2odeInSeq is $var2ode } ; for $var1 in doc("/abc.xml")//b let $count := fn:count($var1/c) for $var2 in 1 to $count where ($count > 1 and fn:not(($var2 + 1) >= $count)) return for $var3 in ($var2 + 1) to $count where functx:is-node-in-sequence($m/citation[$var3], $m/citation) return xdmp:node-delete($m/c [$var3]) But, I am getting xdmp:conflictingupdates exception. Please suggest an alternative to get the desired output. Regards, Nachiketa Kulkarni **************** CAUTION - Disclaimer ***************** This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS******** End of Disclaimer ********INFOSYS*** This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
