Example usage for org.jdom2.xpath XPathExpression getNamespace

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

Introduction

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

Prototype

public Namespace getNamespace(String prefix);

Source Link

Document

Get the Namespace associated with a given prefix.

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  w  ww . ja  va 2s .c  om

        //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;
}