MarkLogic 12 EA 1 Product Documentation
op.xmlDocument

op.xmlDocument(
   rootContent as String
) as documentNode

Summary

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

Parameters
rootContent The XML node used to construct the XML document.

Example

const op = require('/MarkLogic/optic');

const literals = op.fromLiterals([
            {row:1, gp: 1, nm:"alpha", str:"a", num:10, bool:true},
            {row:2, gp: 1, nm:"beta", str:"b", num:20, bool:false},
            {row:3, gp: 2, nm:"gamma", str:"c", num:30, bool:true},
            {row:4, gp: 2, nm:"delta", str:"d", num:40, bool:false}
	          ])
literals.where(op.eq(op.col('gp'), 1))
        .select(['row',
                 op.as('node',
                       op.xmlDocument(
                          op.xmlElement(op.col('nm'),
                                        null,
                                        op.xmlElement(op.col('str'),
                                        null,
                                        op.xmlText(op.col('bool')))
	                       )
	                )),
                 op.as('kind', op.xdmp.nodeKind(op.col('node')))
               ])
        .orderBy('row')
        .result();
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy