for (QName variable : exp.getAllUnboundExternalVariables()) {
// Evaluate referenced variable
Object value = variableResolver.resolveVariable(variable);
// Figure out type of variable
XQSequenceType xqType = getItemType(xqconn, value);
// Saxon doesn't like binding sequences to variables
if (value instanceof Node) {
// a node is a node-list, but the inverse isn't true.
// so, if the value is truly a node, leave it alone.