Description
The functx:is-ancestor function returns a boolean value indicating whether $node1 is an ancestor of $node2 .
Arguments and Return TypeName | Type | Description |
$node1 |
node() |
the first node |
$node2 |
node() |
the second node |
return value |
xs:boolean |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:is-ancestor" as="xs:boolean"
xmlns:functx="http://www.functx.com">
<xsl:param name="node1" as="node()"/>
<xsl:param name="node2" as="node()"/>
<xsl:sequence select="
exists($node1 intersect $node2/ancestor::node())
"/>
</xsl:function>
|
Examples<xsl:variable name="in-xml" as="item()*"> | | <authors>
<author>
<fName>Kate</fName>
<lName>Jones</lName>
</author>
<author>
<fName>John</fName>
<lName>Doe</lName>
</author>
</authors> |
| </xsl:variable> |
XPath 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 |
Recommended Reading:
|