Loading TOC...


   $temporal-collection as xs:string,
   $old as node(),
   $new as node(),
   [$temporal-doc-uri as xs:string]
) as empty-sequence()


Replaces a node in a temporal document.

temporal-collection The URI for the protected temporal collection in which the document is to belong. This must have been previously created by the temporal:collection-create function. All versions of the temporal document will be associated with this temporal collection.
old The old node, to be replaced.
new The new node.
temporal-doc-uri The URI of the temporal document to be updated.

Usage Notes

The forth argument "temporal-doc-uri" is not required for documents inserted with MarkLogic 9.0 version of temporal:document-insert or later.

Attribute nodes cannot be replaced by non-attribute nodes. Non-attribute nodes cannot be replaced by attribute nodes. Element nodes cannot have document node children. Document nodes cannot have multiple roots.

If the caller of the function uses function mapping and $old is an empty sequence, the node-replace function may return an empty sequence. It will not return an error.


xquery version "1.0-ml"; 
import module namespace temporal = "http://marklogic.com/xdmp/temporal" 
      at "/MarkLogic/temporal.xqy";

(: create a document :)
let $options :=  
<options xmlns="xdmp:document-insert">
       <map:map xmlns:map="http://marklogic.com/xdmp/map">
         <map:entry key="validStart">
         <map:entry key="validEnd">
    <a><b>bbb</b></a>, $options);

(: add a c node before the b node :)
temporal:node-replace("kool", fn:doc("/example.xml")/a/b,

(: look at the new document :)

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.