op:xml-document

op:xml-document(
   $root as map:map
) as map:map

Summary

This function constructs an XML document with the root content, which must be exactly one node.

Parameters
$root The XML node used to construct the XML document.

Example

xquery version "1.0-ml";

import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";

op:from-literals((
          map:entry("row",1)=>map:with("gp",1)=>map:with("nm","alpha")=>
          map:with("str","a")=>map:with("num",10)=>map:with("bool", true()  ),
          map:entry("row",2)=>map:with("gp",1)=>map:with("nm","beta" )=>
          map:with("str","b")=>map:with("num",20)=>map:with("bool", false() ),
          map:entry("row",3)=>map:with("gp",2)=>map:with("nm","gamma")=>
          map:with("str","c")=>map:with("num",30)=>map:with("bool", true()  ),
          map:entry("row",4)=>map:with("gp",2)=>map:with("nm","delta")=>
          map:with("str","d")=>map:with("num",40)=>map:with("bool", false() )
          ))
	          => op:where(op:eq(op:col("gp"), 1))
              => op:select(("row",
	                  op:as("node", op:xml-document(
	                      op:xml-element(op:col("nm"), (),
	                          op:xml-element(op:col("str"), (), op:xml-text(op:col("bool"))))
	               ))))
	           => op:order-by("row")
	           => op:result()

  
Powered by MarkLogic Server | Terms of Use | Privacy Policy