zero = getArgument(1).eval(docs, contextSequence, contextItem); Sequence inner = getArgument(0).eval(docs, contextSequence, contextItem);
zero = getArgument(1).eval(contextSequence, contextItem); Sequence inner = getArgument(0).eval(contextSequence, contextItem);
	public Sequence eval(DocumentSet docs, Sequence contextSequence, Item contextItem) throws XPathException {		Sequence zero = DoubleValue.ZERO;		if(getArgumentCount() == 2)			zero = getArgument(1).eval(docs, contextSequence, contextItem);		Sequence inner = getArgument(0).eval(docs, contextSequence, contextItem);		if(inner.getLength() == 0)			return zero;				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((ComputableValue)next);		}		return sum;	}