base-uri
The base URI of a node
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.
Parameters |
Description |
|---|---|
arg:node() |
the node to find the base URI of, otherwise uses the context node |
Examples
The examples below use this input document:
<xsl:variable name="cats" select="doc('http://www.functx.com/input/cats.xml')"/>
<!-- content of cats.xml -->
<catalogs>
<catalog name="ACC" xml:base="http://example.org/ACC/">
<product number="443" href="prod443.html"/>
<product number="563" href="prod563.html"/>
</catalog>
<catalog name="WMN" xml:base="http://example.org/WMN/">
<product number="557" href="prod557.html"/>
</catalog>
</catalogs>
XPath |
Results |
|---|---|
base-uri($cats//catalog[1]) |
|
base-uri($cats//catalog[2]/product) |
|
base-uri($cats//catalog[2]/product/@href) |
|
base-uri($cats) |
|
base-uri($cats/catalogs) |