MarkLogic Server 11.0 Product Documentation
op:replace

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

Summary

Replace a node with another node.

Parameters
$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.
$path The path to replace.
$content The new content.

Example

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><action>write4</action></doc>),
    map:entry("uri", '/optic/update/write5.xml')
      =>map:with("doc", <doc><action>write4</action></doc>)
      =>map:with("collections", ("write"))
  )
return op:from-doc-descriptors($doc-descriptors)
=>op:patch(op:col("doc"),op:patch-builder("/")
           =>op:replace("action",<newAction>new</newAction> )
          )
=>op:write(op:doc-cols())
=>op:result()
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy