fn.root( [$arg as Node?] ) as Node?
Returns the root of the tree to which $arg belongs. This will usually, but not necessarily, be a document node.
If $arg is the empty sequence, the empty sequence is returned.
If $arg is a document node, $arg is returned.
If the function is called without an argument, the context item is used as the default argument. If the context item is undefined an error is raised: [err:XPDY0002]. If the context item is not a node an error is raised: [err:XPTY0004].
|$arg||The node whose root node will be returned.|
var doc = fn.head(xdmp.unquote('<a><quantity>5.0</quantity></a>') ); fn.root(doc); => <?xml version="1.0" encoding="UTF-8"?> <a><quantity>5.0</quantity></a>