exist
exist copied to clipboard
[BUG] xmldiff:compare catches an exception
Describe the bug
in a number of cases xmldiff:compare#2 returns exerr:ERROR An exception occurred while serializing node for comparison: Caught exception during comparison
Expected behavior
I expect false() to be returned, or true(), see tests below.
To Reproduce
xquery version "3.1";
module namespace t="http://exist-db.org/xquery/test";
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare %test:assertTrue function t:test-with-two-identical-nodes-succeeds() {
let $a := (<foo/>)
let $b := (<foo/>)
return
xmldiff:compare($a, $b)
};
declare %test:assertFalse function t:test-with-two-different-nodes-succeeds() {
let $a := (<foo bar=""/>)
let $b := (<foo/>)
return
xmldiff:compare($a, $b)
};
declare %test:assertTrue function t:test-with-two-identical-node-sequences-fails() {
let $a := (<foo/>,<bar/>)
let $b := (<foo/>,<bar/>)
return
xmldiff:compare($a, $b)
};
declare %test:assertFalse function t:test-with-two-different-node-sequences-fails() {
let $a := (<foo/>,<bar/>)
let $b := (<foo/>,<meh/>)
return
xmldiff:compare($a, $b)
};
declare %test:assertFalse function t:test-with-sequences-of-unequal-length-fails() {
let $a := (<foo/>,<bar/>)
let $b := (<foo/>)
return
xmldiff:compare($a, $b)
};
declare %test:assertFalse function t:test-with-sequence-of-two-and-empty-sequence-succeeds() {
let $a := (<foo/>,<bar/>)
let $b := ()
return
xmldiff:compare($a, $b)
};
I think the reason why the pattern is the way it is (with the last test succeeding), is that there is a false thrown after the first node comparison. I think the function cannot compare more than one node, although the signature says it does: xmldiff:compare($node-set-1 as node()*, $node-set-2 as node()*)
exist 5.3.0, windows 10, amazon corretto 1.8.282