ValueSet values = new ValueSet(); NodeSet args = (NodeSet) getArgument(0).eval(docs, context, null).getNodeList();
NodeSet args = (NodeSet) getArgument(0).eval(context, docs, contextSet, contextNode).getNodeList(); LOG.debug("found " + args.getLength() + " nodes for sum"); String nval;
    public Value eval(DocumentSet docs, NodeSet context, NodeProxy node) {		double sum = 0.0, val;		// does argument return a node list?		if(getArgument(0).returnsType() == Constants.TYPE_NODELIST) {			ValueSet values = new ValueSet();			NodeSet args = (NodeSet) getArgument(0).eval(docs, context, null).getNodeList();			for(int i = 0; i < args.getLength(); i++) {				try {					val = Double.parseDouble(args.get(i).getNodeValue());					if(val != Double.NaN)						sum += val;				} catch (NumberFormatException nfe) {				}			}		} else {			// does argument return a value set?			Value v = getArgument(0).eval(docs, context, null);			if(v.getType() == Value.isValueSet) {				for(int i = 0; i < v.getLength(); i++) {					val = v.get(i).getNumericValue();					if(val != Double.NaN)						sum += val;				}			} else // single value				return v;		}		return new ValueNumber(sum);	}