Loading TOC...

temporal.nodeReplace

temporal.nodeReplace(
   $temporal-collection as String,
   $old as Node,
   $new as Node,
   [$temporal-doc-uri as String]
) as null

Summary

Replaces a node in a temporal document.

Parameters
$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:collectionCreate 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:documentInsert 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.

Example

// assume /foo.json is {"foo":"some value"}
// assume tempcol is a temporal collection
declareUpdate();
var doc = cts.doc("/foo.json");
var docObj = doc.toObject();
docObj.foo = "this is a different value";
temporal.nodeReplace("tempcol", doc, docObj);
// now /foo.json will look like: {"foo":"this is a different value"}

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