DocumentSet docs = new DocumentSet(); if (getArgumentCount() == 0) context.getBroker().getAllDocuments(docs); else { for(int i = 0; i < getArgumentCount(); i++) { Sequence seq = getArgument(i).eval(contextSequence, contextItem); for(SequenceIterator j = seq.iterate(); j.hasNext(); ) { String next = j.nextItem().getStringValue(); if(next.length() == 0) throw new XPathException("Invalid argument to fn:doc function: empty string is not allowed here."); if(next.charAt(0) != '/') next = context.getBaseURI() + '/' + next; try { DocumentImpl doc = (DocumentImpl) context.getBroker().getDocument(next); if(doc != null) docs.add(doc); } catch (PermissionDeniedException e) { throw new XPathException("Permission denied: unable to load document " + next); }
DocumentSet docs = null; if (getArgumentCount() == 0) { if(cached != null) return cached; docs = new DocumentSet(); context.getBroker().getAllDocuments(docs); } else { List args = getParameterValues(contextSequence, contextItem); boolean cacheIsValid = false; if(cachedArgs != null) cacheIsValid = compareArguments(cachedArgs, args); if(cacheIsValid) return cached; 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."); if(next.charAt(0) != '/') next = context.getBaseURI() + '/' + next; try { DocumentImpl doc = (DocumentImpl) context.getBroker().getDocument(next); if(doc != null) docs.add(doc); } catch (PermissionDeniedException e) { throw new XPathException("Permission denied: unable to load document " + next);
	public Sequence eval(		Sequence contextSequence,		Item contextItem)		throws XPathException {		DocumentSet docs = new DocumentSet();		if (getArgumentCount() == 0)			context.getBroker().getAllDocuments(docs);		else {			for(int i = 0; i < getArgumentCount(); i++) {				Sequence seq = getArgument(i).eval(contextSequence, contextItem);				for(SequenceIterator j = seq.iterate(); j.hasNext(); ) {					String next = j.nextItem().getStringValue();					if(next.length() == 0)						throw new XPathException("Invalid argument to fn:doc function: empty string is not allowed here.");					if(next.charAt(0) != '/')						next = context.getBaseURI() + '/' + next;					try {						DocumentImpl doc = (DocumentImpl) context.getBroker().getDocument(next);						if(doc != null)							docs.add(doc);					} catch (PermissionDeniedException e) {						throw new XPathException("Permission denied: unable to load document " + next);					}				}			}		}		NodeSet result = new ExtArrayNodeSet(docs.getLength(), 1);		for (Iterator i = docs.iterator(); i.hasNext();) {			result.add(new NodeProxy((DocumentImpl) i.next(), -1));		}		return result;	}