Example usage for org.jdom2.xpath XPathExpression getExpression

List of usage examples for org.jdom2.xpath XPathExpression getExpression

Introduction

In this page you can find the example usage for org.jdom2.xpath XPathExpression getExpression.

Prototype

public String getExpression();

Source Link

Document

Get the XPath expression

Usage

From source file:org.xflatdb.xflat.util.XPathExpressionEqualityMatcher.java

License:Apache License

private static List<String> tokenizeExpression(XPathExpression<?> expression) {
    String exp = expression.getExpression();

    List<String> ret = new ArrayList<>();
    Matcher matcher = nsPattern.matcher(exp);
    int index = 0;
    while (matcher.find()) {
        if (matcher.start() > index) {
            ret.add(exp.substring(index, matcher.start() - index));
        }//from ww w.j  a  va  2 s .com

        //translate namespace prefix to full ns 
        String prefix = matcher.group(1);
        ret.add(expression.getNamespace(prefix).getURI());

        index = matcher.end();
    }

    if (index < exp.length()) {
        ret.add(exp.substring(index));
    }

    return ret;
}