context.setModuleLoadPath("xmldb:exist:
context.setModuleLoadPath(XmldbURI.EMBEDDED_SERVER_URI.append(resource.getCollection().getURI()).toString());
    private String executeXQuery(DBBroker broker, DocumentImpl resource,            HttpServletRequest request, HttpServletResponse response,            Properties outputProperties) throws XPathException, BadRequestException {        Source source = new DBSource(broker, (BinaryDocument)resource, true);        XQuery xquery = broker.getXQueryService();        XQueryPool pool = xquery.getXQueryPool();        XQueryContext context;        CompiledXQuery compiled = pool.borrowCompiledXQuery(broker, source);        if(compiled == null) {        	// special header to indicate that the query is not returned from cache        	response.setHeader("X-XQuery-Cached", "false");            context = xquery.newContext(AccessContext.REST);    	} else {        	response.setHeader("X-XQuery-Cached", "true");            context = compiled.getContext();        }        context.setModuleLoadPath("xmldb:exist://" + resource.getCollection().getURI());        context.setStaticallyKnownDocuments(                 new XmldbURI[] { resource.getCollection().getURI() }        );        declareVariables(context, request, response);        if(compiled == null) {            try {                compiled = xquery.compile(context, source);            } catch (IOException e) {                throw new BadRequestException("Failed to read query from " + resource.getURI(), e);            }        }        checkPragmas(context, outputProperties);        try {            Sequence result = xquery.execute(compiled, null);            return printResults(broker, result, -1, 1, 0, outputProperties, false);        } finally {            pool.returnCompiledXQuery(source, compiled);        }    }