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);
}
if (doc != null) {
selector.setContextItem(doc);
}
XdmNode element = null;
Iterator<XdmItem> values = selector.iterator();
while (values.hasNext()) {
XdmItem item = values.next();
if (element != null || item.isAtomicValue()) {
throw XProcException.dynamicError(9);
}