private void readSource() {
initialized = true;
try {
NamespaceBinding bindings = new NamespaceBinding(runtime,context);
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(context.getBaseURI());
IndependentContext icontext = (IndependentContext) xcomp.getUnderlyingStaticContext();
Hashtable<QName, RuntimeValue> inScopeOptions = new Hashtable<QName, RuntimeValue> ();
try {
inScopeOptions = ((XCompoundStep) forStep).getInScopeOptions();
} catch (ClassCastException cce) {
// FIXME: Surely there's a better way to do this!!!
}
Hashtable<QName, RuntimeValue> boundOpts = new Hashtable<QName, RuntimeValue> ();
for (QName name : inScopeOptions.keySet()) {
RuntimeValue v = inScopeOptions.get(name);
if (v.initialized()) {
boundOpts.put(name, v);
}
}
for (QName varname : boundOpts.keySet()) {
xcomp.declareVariable(varname);
}
for (String prefix : bindings.getNamespaceBindings().keySet()) {
xcomp.declareNamespace(prefix, bindings.getNamespaceBindings().get(prefix));
}
XPathExecutable xexec = xcomp.compile(select);
selector = xexec.load();