home contribute faq download

FunctX XSLT Functions

fn:name

The qualified name of a node, as a string

Google
Webdatypic.com

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 Type

NameType
$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 ExampleResults
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 Also

fn:local-nameThe local part of a node's name
fn:node-nameThe qualified name of a node, as a QName

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 XSLT Services

Recommended Reading:

XQuery