Description
The functx:is-ancestor function returns a boolean value indicating whether $node1 is an ancestor of $node2.
Arguments and Return Type| Name | Type | Description |
$node1 |
node() |
the first node |
$node2 |
node() |
the second node |
| return value |
xs:boolean |
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:is-ancestor
( $node1 as node() ,
$node2 as node() ) as xs:boolean {
exists($node1 intersect $node2/ancestor::node())
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function is-ancestor
( $node1 as node() ,
$node2 as node() ) as xs:boolean {
fn:exists($node1 intersect $node2/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-ancestor(
$in-xml//author[1],
$in-xml//author[1]/fName)
|
true
|
functx:is-ancestor(
$in-xml//author[1]/fName,
$in-xml//author[1])
|
false
|
functx:is-ancestor(
$in-xml//author[1]/fName,
$in-xml//author[1]/fName/text())
|
true
|
functx:is-ancestor(
$in-xml//author[1],
$in-xml//author[2])
|
false
|
See AlsoHistory |
|