Loading TOC...

MarkLogic Server 11.0 Product Documentation
temporal:node-insert-child

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

Summary

Adds a new last child to a node in a temporal document. For XML documents, only element nodes and document nodes can have children. For JSON documents, object nodes and array nodes can have children. Element nodes, object nodes, and array nodes cannot have document node children. Document nodes cannot have multiple roots. On-the-fly constructed nodes cannot be updated. The parameters must specify individual nodes and not node sets.

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:collection-create function. All versions of the temporal document will be associated with this temporal collection.
parent The parent node which will have a new child node.
new The new child node to be inserted.
temporal-doc-uri The URI of the temporal document to be updated.

Usage Notes

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

Example

(: create a document :)
let $options :=  
<options xmlns="xdmp:document-insert">
    <metadata>
       <map:map xmlns:map="http://marklogic.com/xdmp/map">
         <map:entry key="validStart">
           <map:value>2014-04-03T11:00:00</map:value>
         </map:entry>
         <map:entry key="validEnd">
           <map:value>2014-04-03T16:00:00</map:value>
         </map:entry> 
       </map:map>
    </metadata> 
</options> 
return 
temporal:document-insert("tempcol","/example.xml",
    <a/>, $options);

(: insert a child of a :)
temporal:node-insert-child("tempcol",doc("/example.xml")/a,
    <b>bbb</b>);

(: look at the new document :)
fn:doc("/example.xml")
 =>
<?xml version="1.0" encoding="UTF-8"?>
<a><b>bbb</b></a>

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