xf:node-kind

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-kind invocation: expected type node, given type 
[string@http://www.w3.org/2001/XMLSchema] 

If the value of $node-var is the empty sequence, 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-kind invocation: expected type node, given type empty 

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

Signatures

xf:node-kind(xf:node $node-var) —> xs:string

Arguments

Data Type
Argument
Description

node

$node-var

Represents the node from which to determine type.

Returns

Returns a string which represents the kind of $node-var. One of the following strings will be returned: document, element, attribute, text, namespace, processing-instruction, or comment.

Examples

Element

When you invoke the following query:

let $x := <e a="b">c</e>
return <type>{xf:node-kind($x)}</type> 

The following result is generated:

<type>element</type> 

Attribute

When you invoke the following query:

let $x := <e a="b">c</e>
return <type>{xf:node-kind($x/@a)}</type> 

The following result is generated:

<type>attribute</type> 

Text

When you invoke the following query:

let $x := <e a="b">c</e>
return <type>{xf:node-kind($x/text())}</type> 

The following result is generated:

<type>text</type> 

Related Topics

W3C node-kind function description.