root
The root of the tree that contains the argument
Description
The fn:root function returns a document node if the $arg node is part of a document, but it may also return an element if the $arg node is not part of a document.
Calling the fn:root function is similar to starting a path with / or /. It is more flexible in that it can appear anywhere in a path or other expression. Also, unlike starting with a path with /, the fn:root function does not require the root to be a document node; it could be an element in the case of a document fragment.
Parameters |
Description |
---|---|
arg:node() |
the node to find the root of |
Examples
XPath |
Results |
---|---|
root(doc(’http://www.functx.com/input/order.xml’)//item[1]) |
The document node of order.xml |
root($in-xml/x) |
<a> <x>123</x> </a |