Description
The fn:node-name function returns the qualified name of a node as an xs:QName . It is useful only for element, attribute and processing instruction nodes. For elements and attributes, it is simply the names used in XML documents. If the node's name is not in any namespace, the namespace portion of the QName is empty, while the local part is the appropriate name.
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:QName? |
Examplesdeclare namespace pre2 = "http://datypic.com/pre";
declare namespace unpre2 = "http://datypic.com/unpre"; | let $in-xml := | <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> | return |
XQuery Example | Results |
---|
node-name($in-xml) |
A QName whose namespace is empty, whose prefix is empty, and whose local part is 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. |
node-name($in-xml/pre2:prefixed) |
A QName whose namespace is http://datypic.com/pre , whose prefix is pre , and whose local part is prefixed |
node-name($in-xml//unpre2:unprefixed) |
A QName whose namespace is http://datypic.com/unpre , whose prefix is empty, and whose local part is unprefixed |
node-name($in-xml//@pre2:prefAttr) |
A QName whose namespace is http://datypic.com/pre , whose prefix is pre , and whose local part is prefAttr |
node-name($in-xml//@noNSAttr) |
A QName whose namespace is empty, whose prefix is empty, and whose local part is noNSAttr |
See AlsoHistory |
Recommended Reading:
|