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***
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to