Menu

#379 Error when XQuery sort keys are empty

v8.5
closed
5
2014-05-27
2005-08-04
Michael Kay
No

The error "Non-comparable types found while sorting:
Objects are not comparable" may be produced when
sorting in XQuery, if the value of a sort key is an
empty sequence. The problem occurs when lazy evaluation
is used to evaluate the sort key.

Source fix: in net.sf.saxon.sort.SortedTupleIterator,
change the "for" loop at line 57 to read:

        for (int n=1; n<=sortkeys.length; n++) {
            Value v = tuple[n].reduce();
            if (v instanceof EmptySequence) {
                nodeKeys[k+n] = null;
            } else {
                nodeKeys[k+n] = v;
            }
        }

Discussion