home contribute faq download

FunctX XQuery Functions

fn:root

The root of the tree that contains the argument

Google
Webxqueryfunctions.com

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.

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameTypeDescription
$arg node()? the node to find the root of
return value node()?

Examples

let $in-xml :=
<a><x>123</x></a>
return
XQuery ExampleResults
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>

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XQuery Services

Recommended Reading:

XQuery