Description
The fn:namespace-uri-for-prefix function returns the namespace mapped to $prefix, using the in-scope namespaces of $el
e
ment. If $prefix is a zero-length string or the empty sequence, the function returns the default namespace, if any.
This description is © Copyright 2007, O'Reilly Media. 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 Type| Name | Type | Description |
$prefix |
xs:string? |
the prefix to check for |
$element |
element() |
the element to use as the scope |
| 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> |
| XSLT Example | Results |
|---|
namespace-uri-for-prefix(
'', $in-xml)
|
()
|
namespace-uri-for-prefix(
'pre',$in-xml)
|
()
|
namespace-uri-for-prefix(
'pre',$in-xml//pre:prefixed)
|
http://datypic.com/pre
|
namespace-uri-for-prefix(
'',$in-xml//unpre:unprefixed)
|
http://datypic.com/unpre
|
namespace-uri-for-prefix(
'pre',$in-xml//unpre:unprefixed)
|
http://datypic.com/pre
|
See AlsoHistory |
|