int start = ((DoubleValue)arg1.eval(docs, contextSequence).itemAt(0).convertTo(Type.DOUBLE)).getInt();
int start = ((DoubleValue)arg1.eval(contextSequence).itemAt(0).convertTo(Type.DOUBLE)).getInt();
	public Sequence eval(DocumentSet docs, Sequence contextSequence, Item contextItem) throws XPathException {		Expression arg0 = getArgument(0);		Expression arg1 = getArgument(1);		Expression arg2 = null;		if(getArgumentCount() > 2)			arg2 = getArgument(2);		if(contextItem != null)			contextSequence = contextItem.toSequence();		Sequence seq = arg0.eval(docs, contextSequence);		if(seq.getLength() == 0)			return Sequence.EMPTY_SEQUENCE;		int start = ((DoubleValue)arg1.eval(docs, contextSequence).itemAt(0).convertTo(Type.DOUBLE)).getInt();		int length = 0;		if(arg2 != null)			length = ((NumericValue)arg2.eval(docs, contextSequence).				itemAt(0).convertTo(Type.DOUBLE)).getInt();		if(start <= 0 || length < 0)			throw new IllegalArgumentException("Illegal start or length argument");			 		String result = seq.getStringValue();		if(start < 0 || --start + length >= result.length())			return new StringValue("");		return new StringValue((length > 0) ? result.substring(start, start + length) : result.substring(start));	}