Executing the following query with MXQuery SVN snapshot dated 2012-04-04 yields a NPE:
for tumbling window $w in $input
start when true()
end when true()
return $w/(for $i in //random return $i)
"$input" is a sequence of "<random/>" elements. I'm aware that the query could be easily re-formulated, but we require this syntax for certain application-specific reasons.
The following modification to ch.ethz.mxquery.iterators.DocOrderCompare seems to fix the issue:
public class DocOrderCompare implements Comparator {
public int compare(Object o1, Object o2) throws MXQueryException {
Identifier i0 = ((DocOrderObject)o1).getIdentifier();
Identifier i1 = ((DocOrderObject)o2).getIdentifier();
/* start fix */
if(i0 == null || i1 == null)
return 0;
/* end fix */
int c = i0.getStore().compare(i1.getStore());
if(c == 0){
int i = i1.compare(i0);
if(i==0)
return 0;
else if(i==1)
return 1;
else
return -1;
}
else
return c;
}
}