controller.defineGlobalParameters(bindery);
XPathContextMajor context = controller.newXPathContext();
// In tracing/debugging mode, evaluate all the global variables first
TraceListener tracer = controller.getConfiguration().getTraceListener();
if (tracer != null) {
controller.preEvaluateGlobals(context);
tracer.open();
}
context.openStackFrame(stackFrameMap);
if (node != null) {
context.setCurrentIterator(SingletonIterator.makeIterator(node));
controller.setPrincipalSourceDocument(node.getDocumentRoot());
}
boolean mustClose = (result instanceof StreamResult &&
((StreamResult)result).getOutputStream() == null);
context.changeOutputDestination(outputProperties, result, true, Validation.PRESERVE, null);
// Run the query
try {
documentInstruction.process(context);
} catch (XPathException err) {
try {
controller.getErrorListener().fatalError(err);
} catch (TransformerException e) {
//
}
throw err;
}
if (tracer != null) {
tracer.close();
}
context.getReceiver().close();
if (mustClose) {
OutputStream os = ((StreamResult)result).getOutputStream();