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 TypeName | Type | Description |
$node |
node()? |
the node to test |
$seq |
node()* |
the sequence of nodes to search |
return value |
xs:boolean |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:is-node-among-descendants
( $node as node()? ,
$seq as node()* ) as xs:boolean {
some $nodeInSeq in $seq/descendant-or-self::*/(.|@*)
satisfies $nodeInSeq is $node
} ; |
Exampleslet $in-xml := | <prices>
<price value="29.99" discount="10.00"/>
<price value="39.99" discount="6.00"/>
<price value="49.99" discount=""/>
</prices> | let $aPrice := | <price value="49.99" discount=""/> | return |
XQuery Example | Results |
---|
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 AlsoHistory |
Recommended Reading:
|