public static Pattern parse(String text) throws JaxenException, SAXPathException
{
if ( USE_HANDLER )
{
XPathReader reader = XPathReaderFactory.createReader();
PatternHandler handler = new PatternHandler();
handler.setXPathFactory( new DefaultXPathFactory() );
reader.setXPathHandler( handler );
reader.parse( text );
return handler.getPattern();
}
else
{
XPathReader reader = XPathReaderFactory.createReader();
JaxenHandler handler = new JaxenHandler();
handler.setXPathFactory( new DefaultXPathFactory() );
reader.setXPathHandler( handler );
reader.parse( text );
Pattern pattern = convertExpr( handler.getXPathExpr().getRootExpr() );
return pattern.simplify();
}
}