xf:node-name

Returns the expanded QName of $node-var. An expanded QName contains a namespace URI and a local name.

If the value of $node-var is the empty sequence, the following error message is displayed:

Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method: 
Type error in function node-name invocation: expected type node, given type empty 

The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

If a $node-var is not a node, the following error is displayed in the mapper:

Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method: 
Type error in function node-name invocation: expected type node, given type 
[string@http://www.w3.org/2001/XMLSchema] 

Signatures

xf:node-name(xf:node $node-var) —> xs:QName?

Arguments

Data Type
Argument
Description

node

$node-var

Represents the nod to extract the QName from.

Returns

Returns the expanded QName of $node-var. An expanded QName contains a namespace URI and a local name.

Returns the empty sequence for nodes that do not have names (document, text, processing-instruction, comment). The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Examples

Simple

When you invoke the following query:

let $x := <elem xmlns:foo="http://www.acme.org/"><foo:subelem/></elem>,
	$name := xf:node-name(children($x))
	return
		<result>
			<uri>  {
				xf:get-namespace-from-QName($name)  
			}</uri>
			<local>{
				xf:get-local-name-from-QName($name) 
			}</local>
		</result> 

The preceding query generates the following result:

<?xml version="1.0" encoding="UTF-8"?>
<result>
	<uri>http://www.acme.org/</uri>
	<local>subelem</local>
</result> 

Related Topics

W3C node-name function description.