Description
The fn:name function returns the qualified name of a node, as a string. If the node's name is not in a namespace, this function returns the local part of the name, with no prefix. The resulting string is then the namespace prefix, plus a colon (":"), plus the local part. If the name is associated with the default namespace, the resulting name may not be prefixed.
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:string |
Examples<xsl:stylesheet xmlns:pre2="http://datypic.com/pre"
xmlns:unpre2="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 |
---|
name($in-xml) |
noNamespace |
The prefixes pre2 and unpre2 are used rather than pre and unpre to demonstrate that
when selecting nodes from an instance document, it is the
prefix used in the instance document (not the query) that
is returned. |
name($in-xml//pre2:prefixed) |
pre:prefixed |
name($in-xml//unpre2:unprefixed) |
unprefixed |
name($in-xml//@pre2:prefAttr) |
pre:prefAttr |
name($in-xml//@noNSAttr) |
noNSAttr |
See AlsoHistory |
Recommended Reading:
|