if (startValue != null) {
// if sequence is a value, use direct indexing - unless its a Closure!
return SingletonIterator.makeIterator(startValue.itemAt(pos - 1));
}
if (pos >= 1) {
SequenceIterator base = startExp.iterate(context);
return SubsequenceIterator.make(base, pos, pos);
} else {
// index is less than one, no items will be selected
return EmptyIterator.getInstance();
}
} else {
// a non-integer value will never be equal to position()
return EmptyIterator.getInstance();
}
}
// Filter is a value that we can treat as boolean
boolean b;
try {
b = ((Value)filterValue).effectiveBooleanValue();
} catch (XPathException err) {
err.maybeSetLocation(getSourceLocator());
throw err;
}
if (b) {
return start.iterate(context);
} else {
return EmptyIterator.getInstance();
}
} else if (filterValue instanceof NodeInfo) {
return start.iterate(context);
}
}
// get an iterator over the base nodes
SequenceIterator base = startExp.iterate(context);
// quick exit for an empty sequence
if (base instanceof EmptyIterator) {
return base;