home contribute faq download

FunctX XSLT Functions


Whether two nodes have the same content and attributes



The fn:deep-equal function returns true if the $parameter1 and $parameter2 sequences contain the same values, in the same order.

Atomic values are compared based on their typed values, using the eq operator. If two atomic values cannot be compared (e.g. because one is a number, and the other is a string), the function returns false rather than raise an error.

Informally, two nodes are deep-equal if they have all the same attributes and have children (in the same order) who are themselves deep-equal.

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

$parameter1 item()* the first sequence to compare
$parameter2 item()* the second sequence to compare
$collation xs:string the collation to use for comparing strings
return value xs:boolean


<xsl:variable name="prod1" as="item()*">
<product dept='MEN' id='P123'>
<xsl:variable name="prod2" as="item()*">
<product id='P123' dept='MEN'><!--comment-->
XSLT ExampleResults
<deep-equal(>eep-equal( 1, 1 )
<deep-equal(>eep-equal( (1, 1), (1, 1) )
<deep-equal(>eep-equal( (1, 2), (1.0, 2.0) )
<deep-equal(>eep-equal( (1, 2), (2, 1) )
<deep-equal(>eep-equal( $prod1, $prod2 )
<deep-equal(>eep-equal( $prod1/number, $prod2/number )

See Also

functx:sequence-deep-equalWhether two sequences have the same XML node content and/or values
functx:distinct-deepThe XML nodes with distinct values, taking into account attributes and descendants
functx:index-of-deep-equal-nodeThe position of a node in a sequence, based on contents and attributes
functx:is-node-in-sequence-deep-equalWhether an XML node is in a sequence, based on contents and attributes
functx:is-node-among-descendants-deep-equalWhether an XML node is among the descendants of a sequence, based on contents and attributes


Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XSLT Services

Recommended Reading: