base-uri() ➔ xs:anyURI?
Returns the base URI of the context node.
There are no arguments
base-uri($arg as node()?) ➔ xs:anyURI?
Returns the base URI of a specified node.
The node whose base URI is required
Links to W3C specifications
Available in XPath 2.0, XSLT 2.0, XQuery 1.0, and later versions. Available in all Saxon editions.
If a node is supplied to Saxon as a JAXP
Source object, then the base URI of the
document node will be the value returned by the method
Source.getSystemId(). The base URI
of other nodes within the document may differ from this for either of two reasons:
xml:baseattribute may be present on an element to identify the base URI for that element and its contained subtree.
- In the case of documents delivered by a SAX parser, the base URI of nodes constructed from the content of an external entity will reflect the location of that entity.
It is possible for the base URI of a document to be absent (unknown). This happens when the document is
supplied to Saxon with no location information: for example when the node is represented using a tree model such
as DOM that has no base URI information; or when a
Source is supplied for which
returns null. The most common example of this is a
Source created using
new StreamSource(new FileInputStream("input.xml")).
The problem can be fixed by using the second argument of the
StreamSource constructor, or by using the constructor that
File rather than an
If the base URI is absent, the
base-uri() function returns an empty sequence. No error occurs unless an operation
is needed that requires a base URI, for example using the base URI as an argument of