XPath: little code generation improvement

Avoid using a code block with grep just to grep for definedness: an expression is enough.