home contribute faq download

FunctX XSLT Functions

functx:is-node-among-descendants

Whether an XML node is among the descendants of a sequence, based on node identity

Google
Webxsltfunctions.com

Description

The functx:is-node-among-descendants function returns a boolean value indicating whether or not a node is in the specified sequence, or among the descendants of nodes in a sequence, based on node identity. If $node or $seq is the empty sequence, it returns false.

Nodes are identified based on node identity, not their contents. For a similar function based on the contents of a node, see functx:is-node-among-descendants-deep-equal.

Arguments and Return Type

NameTypeDescription
$node node()? the node to test
$seq node()* the sequence of nodes to search
return value xs:boolean

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:is-node-among-descendants" as="xs:boolean"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="node" as="node()?"/>
  <xsl:param name="seq" as="node()*"/>

  <xsl:sequence select="
   some $nodeInSeq in $seq/descendant-or-self::*/(.|@*)
   satisfies $nodeInSeq is $node
 "/>

</xsl:function>

Examples

<xsl:variable name="in-xml" as="item()*">
<prices>
   <price value="29.99" discount="10.00"/>
   <price value="39.99" discount="6.00"/>
   <price value="49.99" discount=""/>
</prices>
</xsl:variable>
<xsl:variable name="aPrice" as="item()*">
<price value="49.99" discount=""/>
</xsl:variable>
XPath ExampleResults
functx:is-node-among-descendants(
     $in-xml/price[1],$in-xml)
true
functx:is-node-among-descendants(
     $in-xml,$in-xml/price[1])
false
functx:is-node-among-descendants(
     $in-xml,$in-xml)
true
functx:is-node-among-descendants(
     $aPrice,$in-xml)
false

See Also

functx:is-node-among-descendants-deep-equalWhether an XML node is among the descendants of a sequence, based on contents and attributes
functx:is-node-in-sequenceWhether an XML node is in a sequence, based on node identity

History

Published OnLast UpdatedContributor(s)
2006-07-092007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery