Search in sources :

Example 1 with DocumentNavigator

use of org.jaxen.dom.DocumentNavigator 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());
}
Also used : Expr(org.jaxen.expr.Expr) LocationPath(org.jaxen.expr.LocationPath) BaseXPath(org.jaxen.BaseXPath) Step(org.jaxen.expr.Step) DocumentNavigator(org.jaxen.dom.DocumentNavigator)

Example 2 with DocumentNavigator

use of org.jaxen.dom.DocumentNavigator 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);
}
Also used : LocationPath(org.jaxen.expr.LocationPath) BaseXPath(org.jaxen.BaseXPath) Element(org.jdom2.Element) NameStep(org.jaxen.expr.NameStep) DocumentNavigator(org.jaxen.dom.DocumentNavigator) Namespace(org.jdom2.Namespace)

Aggregations

BaseXPath (org.jaxen.BaseXPath)2 DocumentNavigator (org.jaxen.dom.DocumentNavigator)2 LocationPath (org.jaxen.expr.LocationPath)2 Expr (org.jaxen.expr.Expr)1 NameStep (org.jaxen.expr.NameStep)1 Step (org.jaxen.expr.Step)1 Element (org.jdom2.Element)1 Namespace (org.jdom2.Namespace)1