name function
The fn:name function returns the prefix and local name parts of a node name.
Syntax
- node
- The qualified name of a node for which the name is to be retrieved. If node is not specified, fn:name is evaluated for the current context node.
Returned value
The returned value depends
on the value of node:
- If node meets any of the following conditions, a string
of length 0 is returned:
- node is the empty sequence.
- node is not an element node, an attribute node, or a processing-instruction node.
- If node meets any of the following conditions, an error
is returned:
- node is undefined.
- node is not a node.
- Otherwise, an xs:string value is returned that contains the prefix (if present) and local name for node.
Examples
The following query returns the
value "comp:emp":
declare namespace d="http://www.mycompany.com";
let $department := document {
<comp:dept xmlns:comp="http://www.mycompany.com" id="A07">
<comp:emp id="31201" />
</comp:dept> }
return fn:name($department/d:dept/d:emp)The
following query also returns the value "comp:emp":
declare namespace d="http://www.mycompany.com";
let $department := document {
<comp:dept xmlns:comp="http://www.mycompany.com" id="A07">
<comp:emp id="31201" />
</comp:dept> }
return $department/d:dept/d:emp/fn:name()