home contribute faq download

FunctX XQuery Functions

fn:node-name

The qualified name of a node, as a QName

Google
Webdatypic.com

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 Type

NameType
$arg node()?
return value xs:QName?

Examples

declare 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 ExampleResults
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 Also

fn:local-nameThe local part of a node's name
fn:nameThe qualified name of a node, as a string
fn:namespace-uriThe namespace URI of a node

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XQuery Services

Recommended Reading:

XQuery