XPathCriteriaEvaluator implements SchematronCriteriaEvaluator { @Override public boolean accepts(ApplicationContext applicationContext, String value, int metadataId, Element metadata, List<Namespace> metadataNamespaces) { String[] ors = value.split(OR); boolean orAccepts = false; for (String or : ors) { String[] ands = or.split(AND); boolean andAccepts = true; for (String and : ands) { andAccepts = doAccept(and, metadata, metadataNamespaces); if (!andAccepts) { break; } } orAccepts = andAccepts; if (orAccepts) { break; } } return orAccepts; }  static SchematronCriteria createAndCriteria(Text... textToMatch); static SchematronCriteria createOrCriteria(Text... textToMatch); static SchematronCriteria createOrCriteria(String... xpaths); static SchematronCriteria createAndCriteria(String... xpaths); @Override boolean accepts(ApplicationContext applicationContext, String value, int metadataId, Element metadata, List<Namespace> metadataNamespaces); @Override boolean accepts(ApplicationContext applicationContext, String value, Element metadata, List<Namespace> metadataNamespaces, Integer groupOwnerId);  }
@Test public void testSlashSlashAtRoot() throws Exception { assertTrue(XPathCriteriaEvaluator.INSTANCE.accepts(null, " assertTrue(XPathCriteriaEvaluator.INSTANCE.accepts(null, " }
@Test public void testAcceptsXPathBoolean() throws Exception { assertTrue(XPathCriteriaEvaluator.INSTANCE.accepts(null, "geonetdebug/text() = 'true'", metadataId, testMetadata, NAMESPACES)); assertTrue(XPathCriteriaEvaluator.INSTANCE.accepts(null, "*/debug/text() = 'true'", metadataId, testMetadata, NAMESPACES)); assertTrue(XPathCriteriaEvaluator.INSTANCE.accepts(null, "* assertFalse(XPathCriteriaEvaluator.INSTANCE.accepts(null, "* assertFalse(XPathCriteriaEvaluator.INSTANCE.accepts(null, "* }
@Test public void testAcceptsXPathString() throws Exception { assertTrue(XPathCriteriaEvaluator.INSTANCE.accepts(null, "* assertFalse(XPathCriteriaEvaluator.INSTANCE.accepts(null, "* assertFalse(XPathCriteriaEvaluator.INSTANCE.accepts(null, "* }
@Test public void testAcceptsXPathElement() throws Exception { assertTrue(XPathCriteriaEvaluator.INSTANCE.accepts(null, "* assertFalse(XPathCriteriaEvaluator.INSTANCE.accepts(null, "* assertTrue(XPathCriteriaEvaluator.INSTANCE.accepts(null, "* assertFalse(XPathCriteriaEvaluator.INSTANCE.accepts(null, "* }
@Test public void testAcceptsXPathError() throws Exception { final XPathCriteriaEvaluator xPathCriteriaEvaluator = new XPathCriteriaEvaluator() { @Override protected void warn(String value, Throwable e) { } }; assertFalse(xPathCriteriaEvaluator.accepts(null, "* }