[FIX] XQuery, StaticVarRef: check if variable exists. Closes #696