home contribute faq download

FunctX XQuery Functions


Resolves a relative URI and references it, returning an XML document



The functx:open-ref-document function takes the value of $refNode, which is a relative URI reference, resolves it to the base URI to form an absolute URI, then calls the fn:doc function to retrieve the document at that URI.

It uses the base URI of the node itself if available (usually the URI the document was retrieved from). If the node doesn't have a base URI, the base URI of the static context is used (which is defined in the prolog or outside the scope of the query by the processor.

Arguments and Return Type

$refNode node() a node whose value is a relative URI reference
return value document-node()

XQuery Function Declaration

See XSLT definition.
declare namespace functx = "http://www.functx.com";
declare function functx:open-ref-document
  ( $refNode as node() )  as document-node() {

   if (base-uri($refNode))
   then doc(resolve-uri($refNode, base-uri($refNode)))
   else doc(resolve-uri($refNode))
 } ;


let $in-xml :=
<a href="temp/other.html">Some other file</a>
XQuery ExampleResultsExplanation
The document node of the document at the relative URI temp/other.html. If the base URI of the $in-xml node is http://datypic.com, it would return http://datypic.com/temp/other.html, assuming it's well-formed XML.

See Also

fn:docOpens a document based on a URI


Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Datypic XQuery Services

Recommended Reading: