this.predicate = predicate;
this.type = type;
}
public boolean next(IFocus focus) throws XQueryException {
final DynamicContext dynEnv = _dynEnv;
Iterator<? extends Item> itor = focus.getBaseFocus();
while(itor.hasNext()) {
int curidx = focus.incrPosition();
Item it = itor.next();
focus.setContextItem(it);
// REVIEWME workaround for fn:last()
dynEnv.pushSequence(_delegate);
// evaluates predicate
IFocus baseFocus = dynEnv.getFocus();
dynEnv.setFocus(focus); // change focus
Sequence cond = predicate.eval(it, dynEnv);
dynEnv.setFocus(baseFocus);
// workaround for fn:last()
dynEnv.popSequence();
if(cond instanceof XInteger) { // positional filtering
final long pos = ((XInteger) cond).getValue();
if(curidx == pos) {
return true;
} else {
continue;
}
}
dynEnv.pushSequence(_delegate);
final boolean ebv = FnBoolean.effectiveBooleanValue(cond, curidx);
dynEnv.popSequence();
if(ebv) {
return true;
} else {
continue;
}