public Sequence eval(DocumentSet docs, Sequence contextSequence, Item contextItem)
public Sequence eval(Sequence contextSequence, Item contextItem)
	public Sequence eval(DocumentSet docs, Sequence contextSequence, Item contextItem)		throws XPathException {		Sequence inner = getArgument(0).eval(docs, contextSequence, contextItem);		if (inner.getLength() == 0)			return Sequence.EMPTY_SEQUENCE;		SequenceIterator iter = inner.iterate();		AtomicValue next = (AtomicValue) iter.nextItem();		if (!Type.subTypeOf(next.getType(), Type.NUMBER))			throw new XPathException(				"Invalid argument to aggregate function. Expected number, got "					+ Type.getTypeName(next.getType()));		ComputableValue sum = (ComputableValue) next;		while (iter.hasNext()) {			next = (AtomicValue) iter.nextItem();			if(next.getType() == Type.ATOMIC)				next = next.convertTo(Type.DOUBLE);			if (!Type.subTypeOf(next.getType(), Type.NUMBER))				throw new XPathException(					"Invalid argument to aggregate function. Expected number, got "						+ Type.getTypeName(next.getType()));			sum = sum.plus((NumericValue) next);		}		return sum.div(new IntegerValue(inner.getLength()));	}