use of org.jaxen.BaseXPath in project pmd by pmd.
the class DocumentNavigatorTest method testXPath.
@Test
public void testXPath() throws JaxenException {
BaseXPath xPath = new BaseXPath(".//*", new DocumentNavigator());
List<?> matches = xPath.selectNodes(rule.statement);
assertEquals(6, matches.size());
}
use of org.jaxen.BaseXPath in project mycore by MyCoRe-Org.
the class MCRRepeatBinding method getElementNameWithPredicates.
@SuppressWarnings("unchecked")
public String getElementNameWithPredicates() throws JaxenException {
BaseXPath baseXPath = new BaseXPath(xPath, new DocumentNavigator());
Expr rootExpr = baseXPath.getRootExpr();
LocationPath locationPath = (LocationPath) rootExpr;
List<Step> steps = locationPath.getSteps();
Step lastStep = steps.get(steps.size() - 1);
return MCRNodeBuilder.simplify(lastStep.getText());
}
use of org.jaxen.BaseXPath in project mycore by MyCoRe-Org.
the class MCRXEditorTransformer method createRootElement.
private Element createRootElement(String xPath) throws JaxenException {
BaseXPath baseXPath = new BaseXPath(xPath, new DocumentNavigator());
LocationPath lp = (LocationPath) (baseXPath.getRootExpr());
NameStep nameStep = (NameStep) (lp.getSteps().get(0));
String prefix = nameStep.getPrefix();
Namespace ns = prefix.isEmpty() ? Namespace.NO_NAMESPACE : MCRConstants.getStandardNamespace(prefix);
return new Element(nameStep.getLocalName(), ns);
}
Aggregations