use of org.mycore.common.xml.MCRXPathEvaluator in project mycore by MyCoRe-Org.
the class MCRXPathTestValidator method validateBinding.
@Override
public boolean validateBinding(MCRValidationResults results, MCRBinding binding) {
// all nodes must validate
boolean isValid = true;
List<Object> boundNodes = binding.getBoundNodes();
for (int i = 0; i < boundNodes.size(); i++) {
Object node = boundNodes.get(i);
String absPath = MCRXPathBuilder.buildXPath(node);
if (results.hasError(absPath)) {
continue;
}
MCRBinding nodeBinding = new MCRBinding(i + 1, binding);
MCRXPathEvaluator evaluator = nodeBinding.getXPathEvaluator();
boolean result = evaluator.test(xPathExpression);
nodeBinding.detach();
results.mark(absPath, result, this);
isValid = isValid && result;
}
return isValid;
}
use of org.mycore.common.xml.MCRXPathEvaluator in project mycore by MyCoRe-Org.
the class MCRJaxenXPathFactoryTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
String builder = "document[name/@id='n1'][note/@href='#n1'][location/@href='#n1'][name[@id='n2']][location[@href='#n2']]";
Element document = new MCRNodeBuilder().buildElement(builder, null, null);
new Document(document);
Map<String, Object> variables = new HashMap<>();
variables.put("CurrentUser", "gast");
evaluator = new MCRXPathEvaluator(variables, document);
}
Aggregations