* Evaluate the function to return an iteration of selected nodes.
*/
public SequenceIterator iterate(XPathContext context) throws XPathException {
SequenceIterator seq = argument[0].iterate(context);
AtomicValue startVal0 = (AtomicValue)argument[1].evaluateItem(context);
NumericValue startVal = (NumericValue)startVal0;
if (argument.length == 2) {
long lstart;
if (startVal instanceof Int64Value) {
lstart = startVal.longValue();
if (lstart <= 1) {
return seq;
}
} else {
startVal = startVal.round();
if (startVal.compareTo(Int64Value.PLUS_ONE) <= 0) {
return seq;
} else if (startVal.compareTo(Int64Value.MAX_LONG) > 0) {
return EmptyIterator.getInstance();
} else if (startVal.isNaN()) {
return EmptyIterator.getInstance();
} else {
lstart = startVal.longValue();
}
}
if (lstart > Integer.MAX_VALUE) {
// we don't allow sequences longer than an this
return EmptyIterator.getInstance();
}
return TailIterator.make(seq, (int)lstart);
} else {
// There are three arguments
AtomicValue lengthVal0 = (AtomicValue)argument[2].evaluateItem(context);
NumericValue lengthVal = (NumericValue)lengthVal0;
if (startVal instanceof Int64Value && lengthVal instanceof Int64Value) {
long lstart = startVal.longValue();
if (lstart > Integer.MAX_VALUE) {