Hi Aparna, I think the issue is that you are trying to do multiple xdmp:node-replace operations on the same document with evals, when that document is already locked by the calling document. This will result in a deadlock, because the calling query is locking the document that eval is trying to update in a separate transaction.
The best way to accomplish this is probably to update the document in memory, and then perform a single update when you are done. To update the nodes in memory, you will have to do a transformation of the document. For a common design pattern for transforming documents, see Chapter 12, "Transforming XML Structures With a Recursive typeswitch Expression," of the Developer's Guide. There is also a nice library in the commons project to do this: http://xqzone.marklogic.com/svn/commons/trunk/ It is called memupdate. I hope that helps. -Danny -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Geert Josten Sent: Friday, November 21, 2008 12:11 AM To: General Mark Logic Developer Discussion Subject: RE: [MarkLogic Dev General] help me: "error : can not updateexternal nodes" I have the impression you sent us a not fully working example. You do a 'cts:search(doc($srcurl)//tu', but there is no tu element in your example.. Kind regards, Geert > Drs. G.P.H. Josten Consultant http://www.daidalos.nl/ Daidalos BV Source of Innovation Hoekeindsehof 1-4 2665 JZ Bleiswijk Tel.: +31 (0) 10 850 1200 Fax: +31 (0) 10 850 1199 http://www.daidalos.nl/ KvK 27164984 De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend. > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Arpitha Chittumalla > Sent: vrijdag 21 november 2008 5:54 > To: [email protected] > Cc: [EMAIL PROTECTED] > Subject: [MarkLogic Dev General] help me: "error : can not > update external nodes" > > Hi, > i am getting error: Can not update external nodes, while node > replace() > In segmentation() i am getting the node, which one need to replcae by > using xdmp:eval(). > i am getting the xpath dynamically, so i used xdmp:eval() > after that, i am passing it to another function to replace node. > i am creating one node by using element. > next i used: > xdmp:node-replace($old-node,$new-node) > > > is any thing wrong here? > can u tell me, wat is the solution. how to solve this problem > i am providing xml and xquery. > > > > **************************xquery************************************ > > xquery version "1.0-ml"; > declare namespace its="http://www.w3.org/2005/11/its"; > > declare function its:segmentation($uri,$path) as node()*{ > let $old-node := concat("doc('", $uri, "')", $path) > for $result at $index in xdmp:eval($old-node) > return ($result) > > }; > > > declare function its:translation($node as node()) as node()* { > > let $trans:= cts:search(doc($srcurl)/termEntry, > cts:word-query(data($node),("case-insensitive"))) > > return if(empty($trans)) > then ( > let $trans:= cts:search(doc($srcurl)//tu, > cts:word-query(data($node),("case-insensitive"))) > > return > > if(empty($trans)) > then ( > $node > (: > let $nodename:=name($node) > > let $new-node:= element {name($node)} { attribute > translation{"false"}, $node/text() } > return ($new-node > ,xdmp:eval(concat("xdmp:node-replace(",xdmp:quote($node),",",x > dmp:quote($new-node),")"))) > :) > ) > > else ( > > let $new-node :=element {name($node)} { > $trans/[EMAIL PROTECTED]:lang="FR-FR"]/seg/text()} > return ($new-node,xdmp:node-replace($node,$new-node)) > > ) > ) > else ( > > let $new-node :=element {name($node)} { > $trans/[EMAIL PROTECTED]:lang="fr"]/tig/term/text()} > > return ($new-node, > xdmp:node-replace($node,$new-node)) > > ) > }; > > for $x in > doc("/trailreplace.xml")//its:[EMAIL PROTECTED]"yes"] > return ( > > for $result at $index in > its:segmentation("/trailreplace.xml",$x/@selector) > return (its:translation($result)) > ) > > > ***************************************************xml******** > ******************************** > > - <report xmlns:its="http://www.w3.org/2005/11/its"> > - <its:rules version="1.0"> > <its:translateRule selector="/report/donorEntry/name" > translate="yes" /> > <its:translateRule selector="/report/donorEntry/note" > translate="yes" /> > <its:translateRule selector="/report/donorEntry/list/donor" > translate="yes" /> > </its:rules> > - <donorEntry> > <name its:translation="yes">Individual donors</name> > <note its:translation="no">Some donors contribute both individually > and through multidonor pooled agreements.</note> > - <list> > <donor its:translation="yes">the Netherlands</donor> > <donor its:translation="yes">Norway</donor> > <donor its:translation="yes">Spain</donor> > <donor its:translation="yes">Sweden</donor> > <donor>Switzerland</donor> > </list> > </donorEntry> > - <donorEntry> > <name its:translation="yes">Africa Technical Assistance > Centers</name> > - <list> > <donor its:translation="yes">African Development Bank</donor> > <donor its:translation="yes">Canada</donor> > <donor its:translation="yes">China</donor> > <donor its:translation="no">Denmark</donor> > <donor its:translation="no">Finland</donor> > </list> > </donorEntry> > </report> > > > ************************************************************** > ************* > > > Thanks and Regards > Aparna. > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
