Loading TOC...


   $patch-builder-plan as map:map,
   $parent-path as xs:string,
   $path-to-replace as xs:string,
   $content as node()
) as map:map


Replace a child if it exist, or insert if it does not exist.

$patch-builder-plan The Patch Builder Plan. You can either use the XQuery => chaining operator or specify the variable that captures the return value from the previous operation.
$parent-path The parent path to insert/replace.
$path-to-replace The path to insert/replace which is relative to parent-path.
$content The new content.


xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";
declare option xdmp:update "true";

let $doc-descriptors := (
    map:entry("uri", '/optic/update/write4.xml')
      =>map:with("doc", <doc><entry><action>write4</action></entry></doc>),
    map:entry("uri", '/optic/update/write5.xml')
      =>map:with("doc", <doc><entry></entry></doc>)
      =>map:with("collections", ("write"))
return op:from-doc-descriptors($doc-descriptors)

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