MarkLogic Server 11.0 Product Documentation
fn:name

fn:name(
   [$arg as node()?]
) as xs:string

Summary

Returns the name of a node, as an xs:string that is either the zero-length string, or has the lexical form of an xs:QName.

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.

Parameters
arg The node whose name is to be returned.

Example

xquery version "1.0-ml";
declare namespace a="a";

let $x := <a:hello/>
return
fn:name($x)

=> a:hello
Powered by MarkLogic Server | Terms of Use | Privacy Policy