((NumericValue)lengthValue.plus(startValue)).getInt() >= string.length()) {
((NumericValue)lengthValue.plus(startValue)).getInt() > string.length()) {
	public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {        if (context.getProfiler().isEnabled()) {            context.getProfiler().start(this);                   context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies()));            if (contextSequence != null)                context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);            if (contextItem != null)                context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());        }                  Expression arg0 = getArgument(0);		Expression arg1 = getArgument(1);		Expression arg2 = null;		if (getArgumentCount() > 2)			arg2 = getArgument(2);		if(contextItem != null)			contextSequence = contextItem.toSequence();                Sequence result;		Sequence seq = arg0.eval(contextSequence);		if(seq.isEmpty())			//If the value of $sourceString is the empty sequence, the zero-length string is returned.			result = StringValue.EMPTY_STRING;        else {    		String string = seq.getStringValue();    		NumericValue startValue = ((NumericValue)(arg1.eval(contextSequence).itemAt(0).convertTo(Type.NUMBER))).round();    		if (startValue.isNaN())    			result = StringValue.EMPTY_STRING;    		else if (startValue.isInfinite())    			result = StringValue.EMPTY_STRING;    		else {    			int start = startValue.getInt();    			    		if (start >= string.length()) 	    			//The characters returned do not extend beyond $sourceString	    			result = StringValue.EMPTY_STRING;    				    		else if (arg2 == null) {	    			//If $startingLoc is zero or negative, only those characters in positions greater than zero are returned.	    			//Because we will substract 1 ;-)	    			if (start < 1)	    				start = 1;	    			result = new StringValue(string.substring(start - 1));	    		} else {	    			NumericValue lengthValue =((NumericValue)(arg2.eval(contextSequence).itemAt(0).convertTo(Type.NUMBER))).round();	    			if (lengthValue.isNaN())	    				result = StringValue.EMPTY_STRING;	    			else if (((NumericValue)lengthValue.plus(startValue)).isInfinite() ||	    					((NumericValue)lengthValue.plus(startValue)).getInt() >= string.length()) {	        			if (start < 0)	        				start = 0;        					        			result = new StringValue(string.substring(start));	    			} else {		    			int length = lengthValue.getInt();		    			//If $startingLoc is zero or negative, only those characters in positions greater than zero are returned.		    			if (start <= 0) {    						    				//Because we will will add 1		    				length = length + start - 1;		    				//Because we will substract 1 ;-)		    				start = 1;		    			}		    			result = new StringValue(string.substring(start - 1, start + length - 1));	    			}	    		}    		}        }                if (context.getProfiler().isEnabled())             context.getProfiler().end(this, "", result);                 return result;            	}