xpointer = checkNamespaces(xpointer);
source = new StringSource(xpointer);
}
final XQuery xquery = serializer.broker.getXQueryService();
final XQueryPool pool = xquery.getXQueryPool();
XQueryContext context;
CompiledXQuery compiled = pool.borrowCompiledXQuery(serializer.broker, source);
if (compiled != null)
{context = compiled.getContext();}
else
{context = xquery.newContext(AccessContext.XINCLUDE);}
context.declareNamespaces(namespaces);
context.declareNamespace("xinclude", XINCLUDE_NS);
//setup the http context if known
if(serializer.httpContext != null)
{
if(serializer.httpContext.getRequest() != null)
{context.declareVariable(RequestModule.PREFIX + ":request", serializer.httpContext.getRequest());}
if(serializer.httpContext.getResponse() != null)
{context.declareVariable(ResponseModule.PREFIX + ":response", serializer.httpContext.getResponse());}
if(serializer.httpContext.getSession() != null)
{context.declareVariable(SessionModule.PREFIX + ":session", serializer.httpContext.getSession());}
}
//TODO: change these to putting the XmldbURI in, but we need to warn users!
if(document!=null){
context.declareVariable("xinclude:current-doc", document.getFileURI().toString());
context.declareVariable("xinclude:current-collection", document.getCollection().getURI().toString());
}
if (xpointer != null) {
if(doc != null)
{context.setStaticallyKnownDocuments(new XmldbURI[] { doc.getURI() } );}
else if (docUri != null)
{context.setStaticallyKnownDocuments(new XmldbURI[] { docUri });}
}
// pass parameters as variables
if (params != null) {
for (final Map.Entry<String, String> entry : params.entrySet()) {
context.declareVariable(entry.getKey(), entry.getValue());
}
}
if(compiled == null) {
try {