home contribute faq download

FunctX XQuery Functions

fn:base-uri

The base URI of a node

Google
Webdatypic.com

Description

The fn:base-uri function finds the base URI of a node. The $arg argument may be any kind of node. If $arg is a document node, this function usually returns the URI from which the document was retrieved. This can also be achieved by the fn:document-uri function.

If $arg is an element, the function returns the value of its xml:base attribute, if any, or the xml:base attribute of its nearest ancestor. If no xml:base attributes appear among its ancestors, it defaults to the base URI of the document node.

If $arg is any other kind of node, the function returns the same value as if the argument were its parent element or document.

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 base URI of, otherwise uses the context node
return value xs:anyURI?

Examples

let $cats :=
doc('http://www.datypic.com/functx./input/cats.xml')
return
XQuery ExampleResults
base-uri($cats//catalog[1])
http://example.org/ACC/
base-uri($cats//catalog[2]/product)
http://example.org/WMN/
base-uri($cats//catalog[2]/product/@href)
http://example.org/WMN/
base-uri($cats)
http://www.functx.com/input/cats.xml
base-uri($cats/catalogs)
http://www.functx.com/input/cats.xml

See Also

fn:resolve-uriResolves a relative URI to a base URI, returning an absolute URI
functx:is-absolute-uriWhether a URI is absolute
fn:static-base-uriThe base URI from the static context
fn:document-uriThe URI of a document

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