Fix bugs in XQuery lexer. Add safeguard to avoid infinite loop in the XQuery lexer.