/**
* Iterate over the sequence of values
*/
public SequenceIterator iterate(XPathContext context) throws XPathException {
SequenceIterator base = operand.iterate(context);
// If the base iterator knows how many items there are, then check it now rather than wasting time
if ((base.getProperties() & SequenceIterator.LAST_POSITION_FINDER) != 0) {
int count = ((LastPositionFinder)base).getLastPosition();
if (count == 0 && !Cardinality.allowsZero(requiredCardinality)) {
typeError("An empty sequence is not allowed as the " +
role.getMessage(), role.getErrorCode(), context);
} else if (count == 1 && requiredCardinality == StaticProperty.EMPTY) {
typeError("The only value allowed for the " +
role.getMessage() + " is an empty sequence", role.getErrorCode(), context);
} else if (count > 1 && !Cardinality.allowsMany(requiredCardinality)) {
typeError("A sequence of more than one item is not allowed as the " +
role.getMessage() + depictSequenceStart(base.getAnother(), 2),
role.getErrorCode(), context);
}
return base;
}