public void compileEventHandler(String expr, XPathEventHandler eventHandler) {
String varName = "obj" + vars.size();
vars.put(varName, eventHandler);
ParserBuilder xpathBuilder = parserBldr;
try {
org.jaxen.saxpath.XPathReader reader = XPathReaderFactory.createReader();
JaxenHandler handler = new JaxenHandler();
reader.setXPathHandler(handler);
reader.parse(expr);
XPathExpr path = handler.getXPathExpr(true);
Object o = handleExpression(parserBldr, path.getRootExpr());
if (o instanceof ExpressionState) {
ExpressionState exp = (ExpressionState) o;
JVar var = exp.getVar();
ParserBuilder builder = exp.getBuilder();
JBlock block = builder.getBody().getBlock();
xpathBuilder = builder.newState(block._if(var)._then());
} else {
xpathBuilder = (ParserBuilder) o;
}
} catch (SAXPathException e) {
throw new XPathException(e);