XmldbURI collectionPath = docPath.removeLastSegment();
XmldbURI path = VersioningTrigger.VERSIONS_COLLECTION.append(collectionPath);
XQuery xquery = broker.getXQueryService();
XQueryPool pool = xquery.getXQueryPool();
XQueryContext context;
CompiledXQuery compiled = pool.borrowCompiledXQuery(broker, GET_BASE_REV_FOR_KEY_SOURCE);
if(compiled == null)
context = xquery.newContext(AccessContext.VALIDATION_INTERNAL);
else
context = compiled.getContext();
context.declareVariable("collection", path.toString());
context.declareVariable("document", docName);
context.declareVariable("base", new IntegerValue(baseRev));
context.declareVariable("key", sessionKey);