Name
namespace-uri()
Returns the namespace URI of the argument node.
Syntax
[1.0] stringnamespace-uri(node-set?)[2.0] xs:anyURInamespace-uri()[2.0] xs:anyURInamespace-uri(node()?)
Inputs
[1.0] A node-set. If the node-set is
omitted, the namespace-uri() function creates a
node-set that has the context node as its only member.
[2.0] A node. If the node is omitted,
the namespace-uri()
function is evaluated against the context item. If the input is a
sequence with more than one node, the XSLT processor raises an
error.
Output
[1.0] The namespace URI of the first node in the argument node-set. If the argument node-set is empty, the first node has no namespace URI, or the first node has a namespace URI that is null, an empty string is returned.
[2.0] The namespace URI of the argument node. If the argument is the empty sequence, the argument has no namespace URI or the node has a namespace URI that is null, an empty string is returned.
Be aware that the namespace-uri() function returns an
empty string for all nodes other than element and attribute
nodes.
Defined in
[1.0] XPath section 4.1, “Node Set Functions.”
[2.0] XQuery 1.0 and XPath 2.0 Functions and Operators section 14, “Functions and Operators on Nodes.”
Example
We’ll use a slightly modified version of our Shakespearean
sonnet to illustrate the namespace-uri() function:
<?xml version="1.0"?> <!-- sonnet-namespace.xml --> <sonnet type='Shakespearean' xmlns="http://www.oreilly.com/xslt"> <author xmlns="http://www.authors.com/"> <last-name>Shakespeare</last-name> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access