private boolean isInstance(SequenceIterator iter, XPathContext context) throws XPathException { int count = 0; while (true) { Item item = iter.next(); if (item == null) break; count++; if (!targetType.matchesItem(item, false, context.getConfiguration())) { return false; } if (count == 2 && !Cardinality.allowsMany(targetCardinality)) { return false; } } return !(count == 0 && ((targetCardinality & StaticProperty.ALLOWS_ZERO) == 0)); }