[2.0] deep-equal()

Compares two sequences of items to see whether they and all their descendants are equal.


xs:boolean deep-equal(item()*, item()*)
xs:boolean deep-equal(item()*, item()*, $collation as xs:string)


Two sequences of items. An optional third argument identifies a collation that should be used when comparing string values. (The collation is not used when comparing node names, so <strasse> and <straße> are never equal, even though a German collation might find those string values to be the same.)


true if the items are deep-equal to each other; false otherwise. Given the variety of types of items in XSLT 2.0, the rules for two sequences being deep-equal are somewhat complicated:

  • If both values are empty sequences, deep-equal() returns true.

  • If the two values are sequences of different lengths (count($value1) != count($value2)), deep-equal() returns false.

  • If the two values are nodes of different kinds (an element and an attribute, for example), deep-equal() returns false.

  • If the two values are document nodes, they are equal only if $value1/(*|text()) is deep-equal to $value2/(*|text()).

  • If the two values are element nodes, they must have the same name and the same number of attributes. Also, those attributes must have the same values, and children must all be deep-equal.

  • The remaining node types (attributes, processing instructions, comments, and text) are straightforward. For attributes and processing instructions, they must have the same name and the same ...

Get XSLT, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.