Description
The functx:is-descendant function returns a boolean value indicating whether $node1 is a descendant of $node2 .
Arguments and Return TypeName | Type | Description |
$node1 |
node() |
the first node |
$node2 |
node() |
the second node |
return value |
xs:boolean |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:is-descendant
( $node1 as node() ,
$node2 as node() ) as xs:boolean {
boolean($node2 intersect $node1/ancestor::node())
} ; |
Exampleslet $in-xml := | <authors>
<author>
<fName>Kate</fName>
<lName>Jones</lName>
</author>
<author>
<fName>John</fName>
<lName>Doe</lName>
</author>
</authors> | return |
XQuery Example | Results |
---|
functx:is-descendant(
$in-xml//author[1]/fName,
$in-xml//author[1]) |
true |
functx:is-descendant(
$in-xml//author[1],
$in-xml//author[1]/fName) |
false |
functx:is-descendant(
$in-xml//author[1]/fName/text(),
$in-xml//author[1]/fName) |
true |
functx:is-descendant(
$in-xml//author[1],
$in-xml//author[2]) |
false |
See AlsoHistory |
Recommended Reading:
|