// If no argument is supplied and the context item is undefined an error is raised: [err:XPDY0002].
Item contextItem = dynEnv.contextItem();
if(contextItem == null) {
throw new DynamicError("err:XPDY0002", "ContextItem is not set");
}
String sv = contextItem.stringValue();
// If the value of $arg is the empty sequence, the xs:integer 0 is returned.
return XInteger.valueOf(sv.length());
}
Item first = argv.getItem(0);
final String argstr = first.stringValue();