
op.xpath( columndef as ColumnIdentifier, path as String, [namespaceBindings as Object?] ) as nodeValue
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. The column can be named with a string or a column function such as op.col, op.viewCol, or op.schemaCol, or constructed from an expression with the op.as function. It can also be op.context to refer to the node of the current processing row. |
| path | An XPath (specified as a string) to apply to each node. |
| namespaceBindings | A map of namespace bindings. The keys should be namespace prefixes and the values should be namespace URIs. These namespace bindings will be added to the in-scope namespace bindings in the evaluation of the path. |
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: Get the most useful answers to questions from the MarkLogic community, or ask your own question.