void putVariable(QualifiedName varName, Variable variable) throws XQueryException {
if(variable instanceof GlobalVariable) {
Variable var = vars.get(varName);
if(var != null && !(var instanceof ExternalVariable)) {
throw new XQueryException("err:XQ0049", "Duplicate global variable: " + varName);
}
} else {
if(localVars.contains(varName)) {
throw new XQueryException("err:XQ0049", "Duplicate local variable: " + varName);
}
}
vars.put(varName, variable);
localVars.add(varName);
}