LOG.debug("Loading document: " + next);
	public Sequence eval(		Sequence contextSequence,		Item contextItem)		throws XPathException {	    DocumentSet docs = null;	    Sequence result = null;	    // check if the loaded documents should remain locked        boolean lockOnLoad = context.lockDocumentsOnLoad();        boolean cacheIsValid = false;	    if (getArgumentCount() == 0) {	        if(cached != null) {	            result = cached;	            docs = cachedDocs;	        } else {		        docs = new DocumentSet();		        context.getBroker().getAllXMLResources(docs);	        }	    } else {		    List args = getParameterValues(contextSequence, contextItem);			if(cachedArgs != null)			    cacheIsValid = compareArguments(cachedArgs, args);			if(cacheIsValid) {			    result = cached;			    docs = cachedDocs;			    LOG.debug("Returning cached document set");			} else {				LOG.debug(hashCode() + ": cached: " + (cached != null));				docs = new DocumentSet();				for(int i = 0; i < args.size(); i++) {					String next = (String)args.get(i);					if(next.length() == 0)						throw new XPathException("Invalid argument to fn:doc function: empty string is not allowed here.");					//TODO : use dedicated function in XmldbURI                    if(next.charAt(0) != '/')                        						next = context.getBaseURI() + "/" + next;                    LOG.debug("Loading document: " + next);					try {						DocumentImpl doc = (DocumentImpl) context.getBroker().getXMLResource(next);						if(doc != null) {						    if(!doc.getPermissions().validate(context.getUser(), Permission.READ))							    throw new XPathException("Insufficient privileges to read resource " + next);							docs.add(doc);						}					} catch (PermissionDeniedException e) {						throw new XPathException("Permission denied: unable to load document " + next);					}				}				cachedArgs = args;			}	    }	    try {            if(!cacheIsValid)                // wait for pending updates                docs.lock(false);	        // wait for pending updates			if(result == null) {			    result = new ExtArrayNodeSet(docs.getLength(), 1);                DocumentImpl doc;				for (Iterator i = docs.iterator(); i.hasNext();) {                    doc = (DocumentImpl) i.next();					result.add(new NodeProxy(doc)); //, -1, Node.DOCUMENT_NODE));                    if(lockOnLoad) {                        context.getLockedDocuments().add(doc);                    }				}			}	    } catch (LockException e) {            throw new XPathException(getASTNode(), "Could not acquire lock on document set.");        } finally {            if(!(cacheIsValid || lockOnLoad))                // release all locks                docs.unlock(false);	    }		cached = result;		cachedDocs = docs;		registerUpdateListener();		return result;	}