Loading TOC...

op.xpath

op.xpath(
   $columndef as String,
   $path as String
) as nodeValue

Summary

This function extracts a sequence of child nodes from a column with node values -- especially, the document nodes from a document join. The path is an XPath (specified as a string) to apply to each node to generate a sequence of nodes as an expression value.

Parameters
$columndef The name of the column from which to extract the child nodes.
$path An XPath (specified as a string) to apply to each node.

Example

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

const literals = op.fromLiterals([
            {id:1, val: 2, uri:"/employee1.json"},
            {id:2, val: 4, uri:"/employee2.json"},
            {id:3, val: 6, uri:"/employee3.json"},
            {id:4, val: 8, uri:"/employee4.json"}
            ])
literals.orderBy('id')
	        .joinDoc(op.col('doc'), op.col('uri'))
	        .select(['id', 'val', 'uri',
                   op.as('EmployeeID', op.xpath('doc', '/(Employee/ID|Expenses/EmployeeID)'))
                  ])
	        .result();

  

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