Example usage for org.dom4j InvalidXPathException InvalidXPathException

List of usage examples for org.dom4j InvalidXPathException InvalidXPathException

Introduction

In this page you can find the example usage for org.dom4j InvalidXPathException InvalidXPathException.

Prototype

public InvalidXPathException(String xpath) 

Source Link

Usage

From source file:org.apache.taglibs.xtags.xpath.StylesheetTag.java

License:Apache License

String processAVTs(String text) throws IOException, InvalidXPathException {
    int marker = 0;
    int leftBracket;
    int rightBracket;
    XPath xpath;// w  ww .  java 2 s . co m
    Object context = getInputNodes();

    avtOutput.delete(0, avtOutput.length());

    while ((leftBracket = text.indexOf('{', marker)) > 0) {
        // output all text up to the { 
        avtOutput.append(text.substring(marker, leftBracket));
        rightBracket = text.indexOf('}', leftBracket);
        if (rightBracket < 0) {
            marker = leftBracket; // It's not part of an xpath expression
            // No more valid {xpath} expressions
            break;
        }
        xpath = createXPath(text.substring(leftBracket + 1, rightBracket));
        if (xpath == null) {
            throw new InvalidXPathException(text.substring(leftBracket + 1, rightBracket));
        }
        avtOutput.append(xpath.valueOf(context));
        marker = rightBracket + 1;
    }
    if (marker < text.length()) {
        avtOutput.append(text.substring(marker));
    }

    return avtOutput.toString();
}