home contribute faq download

FunctX XSLT Functions

functx:node-kind

The XML node kind (element, attribute, text, etc.)

Google
Webxsltfunctions.com

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

NameTypeDescription
$nodes node()* the node(s) whose kind you want to determine
return value xs:string*

XSLT Function Declaration

See XQuery definition.
XSLT 2.0 Syntax:
<xsl:function name="functx:node-kind" as="xs:string*"
              xmlns:functx="http://www.functx.com" >
  <xsl:param name="nodes" as="node()*"/>

  <xsl:sequence select="
 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'
 "/>

</xsl:function>

Examples

<xsl:variable name="in-xml" as="item()*">
<in-xml>
   <!-- this is in-xml -->
   <?test see?>
   <a z="2">xyz</a>
 </in-xml>
</xsl:variable>
XSLT ExampleResults
functx:node-kind($in-xml/a)
element
functx:node-kind($in-xml/a/@z)
attribute
functx:node-kind($in-xml/a/text())
text
functx:node-kind(
 doc('http://www.functx.com/input/order.xml'))
document-node

See Also

functx:atomic-typeThe built-in type of an atomic value

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Need XSLT Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley