Loading TOC...

xdmp:with-namespaces

xdmp:with-namespaces(
   $nsbindings as (xs:string*|map:map),
   $expr as item()*
) as item()*

Summary

Evaluates the expression in the context of a specific set of namespace bindings.

Parameters
nsbindings An alternating sequence of prefixes and URIs. Each prefix is bound to the following URI. If the prefix is the empty string, the following URI becaomes the default namespace of the resulting item(s).
expr An expression to evaluate in the context of the given namespace bindings.

Required Privileges

http://marklogic.com/xdmp/privileges/xdmp-with-namespaces

Example


let $version := "1.2" return
xdmp:with-namespaces(("p", fn:concat("http://marklogic.com/p/",$version)),
   <p:bar/>
)

Returns:

   <p:bar xmlns:p="http://marklogic.com/p/1.2"/>

Example

xdmp:with-namespaces(
   ('', 'x'),
   <test>
      <test1>hello</test1>
   </test>
=>
<test xmlns="x">
  <test1>hello</test1>
</test>

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