context.setStaticallyKnownDocuments(docs);
	protected QueryResult doQuery(User user, DBBroker broker, String xpath,			DocumentSet docs, NodeSet contextSet, Hashtable parameters)			throws Exception {		String baseURI = (String) parameters.get(RpcAPI.BASE_URI);		if(docs == null) {			if(baseURI == null)				docs = broker.getAllDocuments(new DocumentSet());			else {				docs = new DocumentSet();				Collection root = broker.getCollection(baseURI);				root.allDocs(broker, docs, true, true);			}		}		Source source = new StringSource(xpath);		XQuery xquery = broker.getXQueryService();		XQueryPool pool = xquery.getXQueryPool();		CompiledXQuery compiled = pool.borrowCompiledXQuery(source);		XQueryContext context;		if(compiled == null)		    context = xquery.newContext();		else		    context = compiled.getContext();		context.setBaseURI(baseURI);		context.setStaticallyKnownDocuments(docs);		Hashtable namespaces = (Hashtable)parameters.get(RpcAPI.NAMESPACES);		if(namespaces != null && namespaces.size() > 0) {			context.declareNamespaces(namespaces);		}		//	declare static variables		Hashtable variableDecls = (Hashtable)parameters.get(RpcAPI.VARIABLES);		if(variableDecls != null) {			for (Iterator i = variableDecls.entrySet().iterator(); i.hasNext();) {				Map.Entry entry = (Map.Entry) i.next();				LOG.debug("declaring " + entry.getKey().toString() + " = " + entry.getValue());				context.declareVariable((String) entry.getKey(), entry.getValue());			}		}		if(compiled == null)		    compiled = xquery.compile(context, source);		checkPragmas(context, parameters);		try {		    long start = System.currentTimeMillis();		    Sequence result = xquery.execute(compiled, contextSet);		    LOG.info("query took " + (System.currentTimeMillis() - start) + "ms.");		    return new QueryResult(context, result);		} finally {		    pool.returnCompiledXQuery(source, compiled);		}	}