MarkLogic 12 EA 1 Product Documentation
op:xml-attribute

op:xml-attribute(
   $name as item(),
   $value as item()
) as map:map

Summary

This function constructs an XML attribute with the name (which can be a string or QName) and atomic value.

Parameters
$name The attribute name.
$value The attribute value.

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:select(("gp",
	                  op:as("re", op:xml-element("relem", (
	                      op:xml-attribute("row", op:col("row")),
	                      op:xml-attribute("nm",  op:col("nm")),
	                      op:xml-attribute("num", op:col("num"))
	                      ))
	                  )))
	          => op:group-by("gp", op:sequence-aggregate("rs", "re"))
	          => op:order-by("gp")
	          => op:select(op:as("container", op:xml-element("gelem",
	                      op:xml-attribute("group", op:col("gp")),
	                      op:xml-element("rows", (), op:col("rs"))
	                      )))
	          => op:result()

  
Powered by MarkLogic Server | Terms of Use | Privacy Policy