Loading TOC...

MarkLogic Server 11.0 Product Documentation
cts:element-walk

cts:element-walk(
   $node as node(),
   $element as xs:QName*,
   $expr as item()*
) as node()

Summary

Returns a copy of the node, replacing any elements found with the specified expression.

Parameters
node A node to run the walk over. The node must be either a document node or an element node; it cannot be a text node.
element The name of elements to replace.
expr An expression with which to replace each match. You can use the variables $cts:node and $cts:action (described below) in the expression.

Usage Notes

There are two built-in variables to represent an element match. These variables can be used inline in the expression parameter.

$cts:node as element()

The matching element node.

$cts:action as xs:string

Use xdmp:set on this to specify what should happen next

"continue"
(default) Walk the next match. If there are no more matches, return all evaluation results.
"skip"
Skip walking any more matches and return all evaluation results.
"break"
Stop walking matches and return all evaluation results.

Example

(:
   Replace every 'name' element with the text "Mary"
:)
let $x := <p>Dear <name/>, thank you for your interest.</p>
return cts:element-walk($x, xs:QName("name"), "Mary")
=>
<p>Dear Mary, thank you for your interest.</p>

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