final Item firstItem = argv.getItem(0);
if(firstItem.isEmpty()) {
// If the value of $sourceString is the empty sequence, the zero-length string is returned.
return XString.valueOf("");
}
final String sourceString = firstItem.stringValue();
final int maxSourceLen = sourceString.length();
final Item secItem = argv.getItem(1);
final XNumber secNum = (XNumber) secItem;
// first character of a string is located at position 1, not position 0.
final int startingLoc = Math.max(0, (int) Math.round(secNum.asDouble() - 1));