Configuration config = null;
Properties props = new Properties();
props.setProperty(OutputKeys.METHOD, "xml");
props.setProperty(OutputKeys.INDENT, "yes");
XQueryExpression exp = implementation.getCompiledExpressionsCache().get(xqExpression);
if (exp == null) {
config = new Configuration();
StaticQueryContext sqc = new StaticQueryContext(config);
exp = sqc.compileQuery(xqExpression);
implementation.getCompiledExpressionsCache().put(xqExpression, exp);
} else {
config = exp.getStaticContext().getConfiguration();
}
Object[] params = prepareParameters(payload, config, props);
DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
// Setting the parameters for function invocation
String methodName = theMethod.getName();
for (int i = 0; i < params.length; i++) {
dynamicContext.setParameter(methodName + "_" + i, params[i]);
}
// Setting references
for (Map.Entry<String, Object> entry : referenceProxies.entrySet()) {
dynamicContext.setParameter(entry.getKey(), entry.getValue());
}
// Setting properties
for (Map.Entry<String, Object> entry : properties.entrySet()) {
dynamicContext.setParameter(entry.getKey(), transformProperty(entry.getValue(), config));
}
SequenceIterator iterator = null;
Configuration oldConfigValue = SaxonDataBindingHelper.CURR_EXECUTING_CONFIG;
SaxonDataBindingHelper.CURR_EXECUTING_CONFIG = config;
try {
iterator = exp.iterator(dynamicContext);
} finally {
SaxonDataBindingHelper.CURR_EXECUTING_CONFIG = oldConfigValue;
}
ItemList list = new ItemList();