final String next = (String)args.get(i);
XmldbURI nextUri = new AnyURIValue(next).toXmldbURI();
if(nextUri.getCollectionPath().length() == 0) {
throw new XPathException(this, "Invalid argument to " + XMLDBModule.PREFIX + ":document() function: empty string is not allowed here.");
}
if(nextUri.numSegments()==1) {
nextUri = context.getBaseURI().toXmldbURI().resolveCollectionPath(nextUri);
}
final DocumentImpl doc = context.getBroker().getResource(nextUri, Permission.READ);
if(doc == null) {
if (context.isRaiseErrorOnFailedRetrieval()) {