// sections in the query that can be safely cached
// if(cached != null) {
// result = cached;
// docs = cachedDocs;
// } else {
MutableDocumentSet mdocs = new DefaultDocumentSet();
try {
context.getBroker().getAllXMLResources(mdocs);
} catch(final PermissionDeniedException pde) {
LOG.error(pde.getMessage(), pde);
throw new XPathException(this, pde);
}
docs = mdocs;
// }
} else {
List<String> args = getParameterValues(contextSequence, contextItem);
if(cachedArgs != null)
{cacheIsValid = compareArguments(cachedArgs, args);}
if(cacheIsValid) {
result = cached;
docs = cachedDocs;
} else {
MutableDocumentSet mdocs = new DefaultDocumentSet();
for(int i = 0; i < args.size(); i++) {
try {
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()) {
throw new XPathException(this, ErrorCodes.FODC0002, "can not access '" + nextUri + "'");
}
}else {
mdocs.add(doc);
}
} catch (final XPathException e) { //From AnyURIValue constructor
e.setLocation(line, column);
logger.error("From AnyURIValue constructor:", e);