debug(xqueryElementDef, scraper, xq);
String xqExpression = xq.toString().trim();
XQueryExternalParamDef[] externalParamDefs = xqueryDef.getExternalParamDefs();
RuntimeConfig runtimeConfig = scraper.getRuntimeConfig();
final StaticQueryContext sqc = runtimeConfig.getStaticQueryContext();
final Configuration config = sqc.getConfiguration();
try {
final XQueryExpression exp = runtimeConfig.getXQueryExpressionPool().getCompiledExpression(xqExpression);
final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
// define external parameters
for (int i = 0; i < externalParamDefs.length; i++) {
XQueryExternalParamDef externalParamDef = externalParamDefs[i];