This section uses the following definition of equality.
XML nodes are the same if the XSLT function generate-id
returns the same value.
Scheme values are the same if they are eq?
.
The same XML nodes are represented as the same Scheme values. The reverse is not true. The same Scheme values can be converted to different XML nodes.
Using eq?
works well for element, root, comment and processing instruction nodes, but attribute and namespace nodes require more sophisticated equality. When XPath returns an attribute node, the SXML node looks something like this:
(@ (attr-name "attr-value"))
On the other side, consider an element node with attributes:
(elem-name (@ (attr-name "attr-value") (attr-name-2 "attr-value-2")))
After getting the attribute attr-name
using the functions car
and cdr
, the SXML node looks like the following:
(attr-name "attr-value")
Obviously, "(@ (attr-name "attr-value"))
" and "(attr-name "attr-value")
" are not equal. To have the property of equality of attribute nodes, XSieve guaranties that the common part of the both expressions "(attr-name "attr-value")
" is the same Scheme value.
Namespace nodes have the same problem, which is handled by analogue.
As result, a node comparator isn't just a call to eq?
. It should correctly handle different forms of attribute and namespace nodes.