home contribute faq download

FunctX XSLT Functions

fn:deep-equal

Whether two nodes have the same content and attributes

Google
Webxsltfunctions.com

Description

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

NameTypeDescription
$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

Examples

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

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

History

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:

XQuery