}
localBindings = nsv.getNamespaceBindings();
} else if (nsbinding.getXPath() != null) {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
for (QName varname : globals.keySet()) {
xcomp.declareVariable(varname);
}
// Make sure the namespace bindings for evaluating the XPath expr are correct
// FIXME: Surely there's a better way to do this?
Hashtable<String,String> lclnsBindings = new Hashtable<String, String>();
NodeInfo inode = nsbinding.getNode().getUnderlyingNode();
NamePool pool = inode.getNamePool();
InscopeNamespaceResolver inscopeNS = new InscopeNamespaceResolver(inode);
Iterator<?> pfxiter = inscopeNS.iteratePrefixes();
while (pfxiter.hasNext()) {
String nspfx = (String)pfxiter.next();
String nsuri = inscopeNS.getURIForPrefix(nspfx, "".equals(nspfx));
lclnsBindings.put(nspfx, nsuri);
}
for (String prefix : lclnsBindings.keySet()) {
xcomp.declareNamespace(prefix, lclnsBindings.get(prefix));
}
XPathExecutable xexec = xcomp.compile(nsbinding.getXPath());
XPathSelector selector = xexec.load();
for (QName varname : globals.keySet()) {
XdmAtomicValue avalue = new XdmAtomicValue(globals.get(varname).getString());
selector.setVariable(varname,avalue);