AtomicValue next = (AtomicValue) iter.nextItem(); if (!Type.subTypeOf(next.getType(), Type.NUMBER)) next = next.convertTo(Type.DOUBLE); ComputableValue sum = (ComputableValue) next;
Item nextItem; AtomicValue nextValue; nextItem = iter.nextItem(); nextValue = nextItem.atomize(); if (!Type.subTypeOf(nextValue.getType(), Type.NUMBER)) nextValue = nextValue.convertTo(Type.DOUBLE); ComputableValue sum = (ComputableValue) nextValue;
	public Sequence eval(Sequence contextSequence, Item contextItem)		throws XPathException {		Sequence inner = getArgument(0).eval(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))			next = next.convertTo(Type.DOUBLE);		ComputableValue sum = (ComputableValue) next;		while (iter.hasNext()) {			next = (AtomicValue) iter.nextItem();			if (!Type.subTypeOf(next.getType(), Type.NUMBER))				next = next.convertTo(Type.DOUBLE);			sum = sum.plus((NumericValue) next);		}		return sum.div(new IntegerValue(inner.getLength()));	}