home contribute faq download

FunctX XSLT Functions

functx:is-node-among-descendants-deep-equal

Whether an XML node is among the descendants of a sequence, based on contents and attributes

Google
Webxsltfunctions.com

Description

The functx:is-node-among-descendants-deep-equal function returns a boolean value indicating whether or not a node has the same contents as a node in a sequence, or one of the descendants of a node in the sequence. It determines whether the nodes have the same content using the built-in fn:deep-equal function. If $node or $seq is the empty sequence, it returns false.

For a similar function based on the identity of a node rather than its contents, see functx:is-node-among-descendants.

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.
XSLT 2.0 Syntax:
<xsl:function name="functx:is-node-among-descendants-deep-equal" 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 deep-equal($nodeInSeq,$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>
<xsl:variable name="anAuthor" as="item()*">
<author>
  <fName>John</fName>
  <lName>Doe</lName>
</author>
</xsl:variable>
<xsl:variable name="anotherAuthor" as="item()*">
<author>
  <lName>Doe</lName>
  <fName>John</fName>
</author>
</xsl:variable>
XSLT ExampleResults
functx:is-node-among-descendants-deep-equal(
     $in-xml/author[1],$in-xml)
true
functx:is-node-among-descendants-deep-equal(
     $anAuthor,$in-xml)
true
functx:is-node-among-descendants-deep-equal(
     $anotherAuthor,$in-xml)
false
functx:is-node-among-descendants-deep-equal(
     $anAuthor,$in-xml/author)
true

See Also

functx:is-node-among-descendantsWhether an XML node is among the descendants of a sequence, based on node identity
functx:is-node-in-sequence-deep-equalWhether an XML node is in a sequence, based on contents and attributes
fn:deep-equalWhether two nodes have the same content and attributes

History

Published OnLast UpdatedContributor(s)
2006-07-092007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Need XSLT Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley