O'Reilly logo

XSLT, 2nd Edition by Doug Tidwell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

namespace-uri()

Returns the namespace URI of the argument node.

Syntax

[1.0] string namespace-uri(node-set?)
[2.0] xs:anyURI namespace-uri()
[2.0] xs:anyURI namespace-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> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required