MarkLogic 10 Product Documentation
op:xpath

op:xpath(
   $column as item(),
   $path as xs:string,
   [$namespaceBindings as map:map?]
) as map:map

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
$column The name of the column from which to extract the child nodes.
$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.

See Also

Example

xquery version "1.0-ml";

import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";

op:from-literals((
	              map:entry("id", 1) => map:with("val", 2) => map:with("uri", "/employee1.json"),
	              map:entry("id", 2) => map:with("val", 4) => map:with("uri", "/employee3.json"),
	              map:entry("id", 3) => map:with("val", 6) => map:with("uri", "/expense4.json")
	              ))
	            => op:order-by("id")
	            => op:join-doc(op:col("doc"), op:col("uri"))
	            => op:select(("id", "val", "uri",
                            op:as("EmployeeID", op:xpath("doc", "/(Employee/ID|Expenses/EmployeeID)"))
                          ))
	            => op:result()
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy