Compares two sequences, with more control than fn:deep-equal().

deep-equal($arg1 as item()*, $arg2 as item()*, $collation as xs:string?, $flags as xs:string) ➔ xs:boolean





The first sequence




The second sequence




Collation used for comparing strings




Flags controlling the way the comparison is performed.




Notes on the Saxon implementation

Introduced in Saxon 8.6.1, with changes (for additional flags) in Saxon 8.7, 9.4, and 9.5.


This function compares two sequences $arg1 and $arg2 for deep equality. The two sequences are supplied in the first two arguments. In the absence of any $flags, the function returns the same result as the deep-equal() function in the standard XPath library. The $flags argument is used to modify the way in which the comparison is performed.

The $collation argument is mandatory. Supply an empty sequence to use the default collation.

The flags argument is a string containing characters acting as flags that cause the function to behave differently from the standard fn:deep-equal() function. The following flags are defined:

N Include namespace nodes in the comparison. For two elements to be deep-equal, they must have the same in-scope namespaces (that is, same prefix and same URI).
F Include namespace prefixes in the comparison. For two elements or attributes to be equal, their names must use the same namespace prefix (or none).
C Include comment nodes in the comparison. For two element or document nodes to be deep-equal, they must have the same comment node children.
P Include processing-instruction nodes in the comparison. For two element or document nodes to be deep-equal, they must have the same processing-instruction node children.
J Join adjacent text nodes (for example, nodes either side of an ignored comment).
S Compare string values rather than typed values of simple-typed elements and attributes.
A Compare type annotations on elements and attributes. The type annotations must match exactly.
I Compare the is-ID and is-IDREF properties on elements and attributes.
w Exclude whitespace text nodes from the comparison. Any whitespace text node in either tree is ignored (except when determining the typed value of an element annotated with a simple type or a complex type with simple content).
v Exclude type variety from the comparison. By default, an element with simple type and an element with complex type are never deep-equal - even if their actual content is identical. Similarly, an element whose content model is empty is never deep-equal to one with an element-only content model, even if both actually have no content. This flag suppresses this check. It is useful when comparing a schema-validated document to an unvalidated document.
? Explain reason for a non-match. If the result is not-equal, a warning message explaining the reason will be sent to the ErrorListener. (In general, a sequence of warning messages will be sent, starting with the lowest-level difference and moving up the tree).

See also: