/** * Validation Xpath query * * @param query xpath query * @return true if xpath query valid */ public boolean isValidXpathQuery(String query) { try { XPathReader reader = new XPathReader(); reader.parse(query); } catch (Exception e) { return false; } return true; }
/** * Validation Xpath query * * @param query xpath query * @return true if xpath query valid */ public boolean isValidXpathQuery(String query) { try { XPathReader reader = new XPathReader(); reader.parse(query); } catch (Exception e) { return false; } return true; }
/** * @param args String[] * @throws SAXPathException */ public static void main(String[] args) throws SAXPathException { XPathReader reader = new XPathReader(); reader.setXPathHandler(new DebugXPathHandler()); reader .parse("/ns:one[@woof='dog']/two/./../two[functionTest(@a, @b, $woof:woof)]/three/*/four//*/five/six[@exists1 and @exists2]"); }
/** * @param args String[] * @throws SAXPathException */ public static void main(String[] args) throws SAXPathException { XPathReader reader = new XPathReader(); reader.setXPathHandler(new DebugXPathHandler()); reader .parse("/ns:one[@woof='dog']/two/./../two[functionTest(@a, @b, $woof:woof)]/three/*/four//*/five/six[@exists1 and @exists2]"); }
static Query getPathQuery(String path) throws SAXPathException { ApplicationContext ac = ApplicationContextHelper.getApplicationContext(); XPathReader reader = new XPathReader(); LuceneXPathHandler handler = new LuceneXPathHandler(); handler.setNamespacePrefixResolver((NamespaceService) ac.getBean("namespaceService")); handler.setDictionaryService((DictionaryService) ac.getBean("dictionaryService")); reader.setXPathHandler(handler); reader.parse(path); PathQuery pathQuery = handler.getQuery(); pathQuery.setRepeats(false); return pathQuery; }
static Query getPathQuery(String path) throws SAXPathException { ApplicationContext ac = ApplicationContextHelper.getApplicationContext(); XPathReader reader = new XPathReader(); LuceneXPathHandler handler = new LuceneXPathHandler(); handler.setNamespacePrefixResolver((NamespaceService) ac.getBean("namespaceService")); handler.setDictionaryService((DictionaryService) ac.getBean("dictionaryService")); reader.setXPathHandler(handler); reader.parse(path); PathQuery pathQuery = handler.getQuery(); pathQuery.setRepeats(false); return pathQuery; }