Sequence seq = expression.eval(contextSequence, contextItem); if(!seq.isEmpty() && requiredCardinality == Cardinality.EMPTY) { error.addArgs(ExpressionDumper.dump(expression), Cardinality.getDescription(requiredCardinality), new Integer(seq.getLength())); throw new XPathException(getASTNode(), error.toString()); } if(seq.isEmpty() && (!Cardinality.checkCardinality(requiredCardinality, Cardinality.ZERO))) { error.addArgs(ExpressionDumper.dump(expression), Cardinality.getDescription(requiredCardinality), new Integer(seq.getLength())); throw new XPathException(getASTNode(), error.toString()); } else if(seq.hasMany() && (!Cardinality.checkCardinality(requiredCardinality, Cardinality.MANY))) { error.addArgs(ExpressionDumper.dump(expression), Cardinality.getDescription(requiredCardinality), new Integer(seq.getLength())); throw new XPathException(getASTNode(), error.toString());
Sequence seq = expression.eval(contextSequence, contextItem);  int actualCardinality; if (seq.isEmpty()) actualCardinality = Cardinality.EMPTY; else if (seq.hasMany()) actualCardinality = Cardinality.MANY; else actualCardinality = Cardinality.ONE;  if (!Cardinality.checkCardinality(requiredCardinality, actualCardinality)) { error.addArgs(ExpressionDumper.dump(expression), Cardinality.getDescription(requiredCardinality), new Integer(seq.getLength())); throw new XPathException(getASTNode(), error.toString());
	public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {        if (context.getProfiler().isEnabled()) {            context.getProfiler().start(this);                   context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies()));            if (contextSequence != null)                context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);            if (contextItem != null)                context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());        }                Sequence seq = expression.eval(contextSequence, contextItem);				if(!seq.isEmpty() && requiredCardinality == Cardinality.EMPTY) {            error.addArgs(ExpressionDumper.dump(expression),                     Cardinality.getDescription(requiredCardinality), new Integer(seq.getLength()));            throw new XPathException(getASTNode(), error.toString());        }		if(seq.isEmpty() && (!Cardinality.checkCardinality(requiredCardinality, Cardinality.ZERO))) {            error.addArgs(ExpressionDumper.dump(expression), Cardinality.getDescription(requiredCardinality),                     new Integer(seq.getLength()));            throw new XPathException(getASTNode(), error.toString());        } else if(seq.hasMany() && (!Cardinality.checkCardinality(requiredCardinality, Cardinality.MANY))) {            error.addArgs(ExpressionDumper.dump(expression), Cardinality.getDescription(requiredCardinality),                     new Integer(seq.getLength()));            throw new XPathException(getASTNode(), error.toString());        }                if (context.getProfiler().isEnabled())                       context.getProfiler().end(this, "", seq);          		return seq;	}