O'Reilly logo

XSLT, 2nd Edition by Doug Tidwell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

[2.0] deep-equal()

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

Syntax

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

Inputs

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.)

Output

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required