XSLT and XPath function reference in alphabetical order
(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)
Node names, identifiers and URI information
The base URI of a node passed on in the form of a xs:string character string.
Optional. The argument is a node whose base URI shall be determined. If no argument is passed on, the base URI of the context item of the function call is returned.
Purpose of use:
The function returns the base URI of all node types having an appropriate base-uri property, which means of document nodes, elements and processing instructions. The returned value is of xs:anyURI type.
If applied to nodes with an empty base-uri property or to node types which have no base-uri property themselves, the function returns the value of the base-uri property of the parent node, provided that it is not empty. If the parent node has an empty base-uri property, this procedure will be repeated recursively (if applicable up to the document node) until a node with a non-empty property is found. If the last node accessible in this way has an empty base-uri property and no parent node, the return value is the empty sequence.
Therefore, for attribute nodes the base URI of the parent element is returned, provided that it is not empty. For namespace nodes (since their parent node does not need to be ascertainable) always the empty sequence is returned.
If the argument passed on is not a node, the type error err:XPTY0004 is reported. If there is no valid static context for the function call, the error err:XPDY0002 is outputted.
Example 1 - function call without argument:
returns for example:
Without any argument passed on, the function returns the base URI of the static context of the function call. Since the call is made from the XSLT stylesheet, its base URI is returned.
Example 2 - function call with argument:
returns for example:
If a XPath expression which refers to a node of the source document (here <test>) is passed on to the function, it returns its base URI. In this case this corresponds to the base URI of the processed XML document.
The function is not available.
fn:base-uri() as xs:anyURI?
fn:base-uri($arg as node()) as xs:anyURI?
|<< back||next >>|
Copyright © Galileo Press, Bonn 2008
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSLT 2.0 & XPath 2.0" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn, Germany