Reputation: 976
I am using mem:node-replace for replacing the content.But it is taking too much of time.I got a time-out error. Is there any alternative for this?
Find the Sample Xquery:
xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";
import module namespace mem = "http://xqdev.com/in-mem-update"
at '/MarkLogic/appservices/utils/in-mem-update.xqy';
let $uri := cts:uri-match((concat('*',$id ,'*')),(),cts:collection-query($collection))
let $data := doc($uri)
let $final := mem:node-replace($data//title[@id='2'],doc($uri1)//title[@id='2'])
return (
xdmp:document-insert('/test/sample.xml',$final)
)
Upvotes: 2
Views: 1041
Reputation: 66783
mem:node-replace()
is not the most efficient way to modify content.
If your documents are already in the database, and you simply want to replace a node, then there is no need to use the in-mem-update library.
You should use xdmp:node-replace()
.
For more complex transformations you might also consider the following options for in-memory transforms:
xdmp:xslt-eval()
with a local XSLT variable, or xdmp:xslt-invoke()
with an XSLT that has been loaded into the Modules database. It is a little different programming style, but can often outperform and be developed more simply using a modified identity transform as a "push style" stylesheet with specific templates for the changes you need to make.If you need to modify an extremely large number of documents, then you still may start to run into timeout issues if you attempt to do it all in a single module execution.
You should look to manage bulk document changes with batch tools, such as:
Upvotes: 5