fn.name( [$arg as Node?] ) as String
Returns the name of a node, as an
xs:string that is either the
zero-length string, or has the lexical form of an
If the argument is omitted, it defaults to the context node. If the context item is undefined an error is raised: [err:XPDY002]. If the context item is not a node an error is raised: [err:XPTY0004].
If the argument is supplied and is the empty sequence, the function returns the zero-length string.
If the target node has no name (that is, if it is a document node, a comment, a text node, or a namespace node having no name), the function returns the zero-length string.
If the specified node was created with a namespace prefix, that namespace
prefix is returned with the element localname (for example,
a:hello). Note that the namespace prefix is not always the same
prefix that would be returned if you serialized the QName of the node, as
the serialized QName will use the namespace from the XQuery context in
which it was serialized.
|$arg||The node whose name is to be returned.|
var x = fn.head(xdmp.unquote('<a:hello xmlns:a="a"/>') ).root.xpath("/element()"); fn.name(x); => a:hello