for (QName variable : exp.getAllUnboundExternalVariables()) {
// Evaluate referenced variable
Object value = variableResolver.resolveVariable(variable);
if (value instanceof Value) {
SaxonXQConnection saxonConn = (SaxonXQConnection) xqconn;
try {
Item item = ((Value) value).asItem();
if (item == null) {
exp.bindSequence(variable, xqconn.createSequence(Collections.EMPTY_LIST.iterator()));
} else {