Description
The fn:namespace-uri function returns the namespace part of the element or attribute name. This is the namespace that is mapped to its prefix, or the default namespace if it is unprefixed. If the element or attribute name is not in a namespace, a zero-length string is returned.
This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book. Arguments and Return TypeName | Type |
$arg |
node()? |
return value |
xs:anyURI |
Examples<xsl:stylesheet xmlns:pre="http://datypic.com/pre"
xmlns:unpre="http://datypic.com/unpre">... | <xsl:variable name="in-xml" as="item()*"> | | <noNamespace>
<pre:prefixed xmlns="http://datypic.com/unpre"
xmlns:pre="http://datypic.com/pre">
<unprefixed pre:prefAttr="a" noNSAttr="b">123</unprefixed>
</pre:prefixed>
</noNamespace> |
| </xsl:variable> |
XPath Example | Results | Explanation |
---|
namespace-uri($in-xml) |
zero-length xs:anyURI value |
the noNamespace element itself |
namespace-uri($in-xml//pre:prefixed) |
http://datypic.com/pre |
namespace-uri($in-xml//unpre:unprefixed) |
http://datypic.com/unpre |
namespace-uri($in-xml//@pre:prefAttr) |
http://datypic.com/pre |
namespace-uri($in-xml//@noNSAttr) |
zero-length xs:anyURI value |
See AlsoHistory |
Recommended Reading:
|