One way you might solve this problem is to create a new result that combines 
the original results with the new results.  You can then save the new result as 
the final step.  The code below shows how this could be done.  The input 
parameter contains the node that will be inserted into the <results/> node.

------------------------------
xquery version "1.0-ml";

declare function local:updatenodes($insertnode)
{
let $uri := "/test.xml"

let $original := fn:doc($uri)

let $results :=
  if(fn:exists($original)) then
    (: Use the original results - note that we need the first element node :)
    $original/element()
  else
    (: Create some initial results :)
    <results foo="bar" bar="baz"/>

(: Add some information to the results :)
let $modifiedResults :=
    (: Use a computed constructor - dynamically get the node name to avoid hard 
coding :)
    element {fn:node-name($results)}
    {
      (: Add back the original attribute nodes :)
      $results/@*,

      (: Add back the original child nodes :)
      $results//*,

      (: Add the new results :)
      $insertnode
    }

(: Save the newly created node to the database using the same uri name :)
let $save := xdmp:document-insert($uri, $modifiedResults)

return $modifiedResults
};

let $insert := <oneResult a="b"/>
return local:updatenodes($insert)

-----------------------------------------

Note that this function can only be called once for a given transaction.  If 
you need to make more than one modification, then you might need to modify the 
function to make all of the changes at once.

Hope this helps.

David 

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Arun
Sent: Monday, February 02, 2009 7:52 AM
To: [email protected]
Subject: [MarkLogic Dev General] Re: passing variables to CPF in Marklogic

Hello ,

I am facing problem in node-updates and insert.
i need to insert data to the url several times, in a same transaction.
when i am doing that,
Marklogic giving error like: " XDMP-CONFLICTINGUPDATES: xdmp:document-insert "
how to insert data in same transaction ?

ex:

decalare function  loc:updatenodes()
{
let $uri:="/test.xml";

 xdmp:document-insert(
$uri,<results/>)
,

 xdmp:document-insert(
$uri,<results><result/></results>)

};

like this

can any one give me solution .................
Thanks in advance.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general


 NOTICE: This email message is for the sole use of the intended recipient(s) 
and may contain confidential and privileged information. Any unauthorized 
review, use, disclosure or distribution is prohibited. If you are not the 
intended recipient, please contact the sender by reply email and destroy all 
copies of the original message.


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

Reply via email to