if(argv == null) {
// If the function is called without an argument, the context item is used
// as the default argument.
Item i = dynEnv.contextItem();
if(i == null) {
throw new DynamicError("err:XPDY0002", "ContextItem is not set");
}
if(i instanceof XQNode) {
((XQNode) i).getRoot();
} else {
throw new DynamicError("err:XPTY0004", "context item is not a node");
}
} else if(argv.size() == 1) {
Item i = argv.getItem(0);
if(i.isEmpty()) {
return ValueSequence.EMPTY_SEQUENCE;
}
if(i instanceof XQNode) {
return ((XQNode) i).getRoot();
}
}
throw new DynamicError("Arguments size of " + SYMBOL + " must be 0 or 1, but was "
+ argv.size());
}