Description
The functx:node-kind function returns the node kind of a node (or sequence of nodes), one of the values "element", "attribute", "text", "comment", "processing-instruction", or "document-node" for each node supplied. If $nodes is the empty sequence, it returns the empty sequence.
Arguments and Return Type| Name | Type | Description |
$nodes |
node()* |
the node(s) whose kind you want to determine |
| return value |
xs:string* |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for July 2004 - January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:node-kind
( $nodes as node()* ) as xs:string* {
for $node in $nodes
return
if ($node instance of element()) then 'element'
else if ($node instance of attribute()) then 'attribute'
else if ($node instance of text()) then 'text'
else if ($node instance of document-node()) then 'document-node'
else if ($node instance of comment()) then 'comment'
else if ($node instance of processing-instruction())
then 'processing-instruction'
else 'unknown'
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function node-kind
( $nodes as node()* ) as xs:string* {
for $node in $nodes
return
if ($node instance of element()) then 'element'
else if ($node instance of attribute()) then 'attribute'
else if ($node instance of text()) then 'text'
else if ($node instance of document-node()) then 'document-node'
else if ($node instance of comment()) then 'comment'
else if ($node instance of processing-instruction())
then 'processing-instruction'
else 'unknown'
} |
Exampleslet $in-xml := | <in-xml>
<!-- this is in-xml -->
<?test see?>
<a z="2">xyz</a>
</in-xml> | return |
| XQuery Example | Results |
|---|
functx:node-kind($in-xml/a)
|
element
|
functx:node-kind($in-xml/a/@z)
|
attribute
|
functx:node-kind($in-xml/comment())
|
comment
|
functx:node-kind(
$in-xml/processing-instruction())
|
processing-instruction
|
functx:node-kind($in-xml/a/text())
|
text
|
functx:node-kind(
doc('http://www.functx.com/input/order.xml'))
|
document-node
|
See AlsoHistory |
|