Loading TOC...

xdmp:node-uri

xdmp:node-uri(
   $node as node()
) as xs:string?

Summary

Returns the document-uri property of the parameter or its ancestor.

Parameters
$node The node whose URI is returned.

Example

xdmp:node-uri(doc("/some/document.xml"))
=> "/some/document.xml"

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

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • How exactly do you use this function in case you want to get the uri of an xml in your DB just with the information of a node containing it?
    • Use it just like the example. If you have a node from the database bound to a variable, just pass that into xdmp:node-uri and it will return the URI. For example: for $node in /foo/bar return xdmp:node-uri($node) This will return the URI for each node in the database that matches the xpath expression (it is in a loop because the xpath returns a sequence of nodes and xdmp:node-uri expects a single node).
    • Unclear what you're asking. I'd recommend you ask this question on StackOverflow our our mailing list. This API call is for when you have a reference to a node from the document itself. The example above uses the document node, but you could have a node anywhere in the document. Like if you had $x := doc('/foo')/bar then you could do $uri := xdmp:node-uri($x) to get back '/foo'. But perhaps you want something else.