if (inner.isEmpty()) {
result = Sequence.EMPTY_SEQUENCE;
} else {
final SequenceIterator iter = inner.iterate();
Item item = iter.nextItem();
AtomicValue value = item.atomize();
//Any values of type xdt:untypedAtomic are cast to xs:double
if (value.getType() == Type.UNTYPED_ATOMIC)
{value = value.convertTo(Type.DOUBLE);}
if (!(value instanceof ComputableValue)) {
throw new XPathException(this, ErrorCodes.FORG0006,
Type.getTypeName(value.getType()) + "(" + value + ") " +
"can not be an operand in a sum", value);
}
//Set the first value
ComputableValue sum = (ComputableValue) value;
while (iter.hasNext()) {
item = iter.nextItem();
value = item.atomize();
//Any value of type xdt:untypedAtomic are cast to xs:double
if (value.getType() == Type.UNTYPED_ATOMIC)
{value = value.convertTo(Type.DOUBLE);}
if (!(value instanceof ComputableValue)) {
throw new XPathException(this, ErrorCodes.FORG0006, "" +
Type.getTypeName(value.getType()) + "(" + value +
") can not be an operand in a sum", value);
}
if (Type.subTypeOf(value.getType(), Type.NUMBER)) {
if (((NumericValue)value).isInfinite())
{gotInfinity = true;}
if (((NumericValue)value).isNaN()) {
sum = DoubleValue.NaN;
break;