op:xml-element( $name as item(), [$attributes as map:map*], [$content as item()*] ) as map:map
This function constructs an XML element with the name (which can be a string or QName), zero or more attributes, and child content. The child content can include a sequence or array of atomic values or an element, comment, or processing instruction nodes. Atomic values are converted to text nodes.
Parameters | |
---|---|
$name | The string or QName for the constructed element. |
$attributes |
Any element attributes returned from op:xml-attribute,
or null if no attributes.
|
$content | A sequence or array of atomic values or an element, a comment from op:xml-comment, or processing instruction nodes from op:xml-pi. |
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()