Search in sources :

Example 1 with CachedXPathAPI

use of org.apache.xpath.CachedXPathAPI in project fess-crawler by codelibs.

the class HtmlTransformer method getXPathAPI.

protected CachedXPathAPI getXPathAPI() {
    CachedXPathAPI cachedXPathAPI = xpathAPI.get();
    if (cachedXPathAPI == null) {
        cachedXPathAPI = new CachedXPathAPI();
        xpathAPI.set(cachedXPathAPI);
    }
    return cachedXPathAPI;
}
Also used : CachedXPathAPI(org.apache.xpath.CachedXPathAPI)

Example 2 with CachedXPathAPI

use of org.apache.xpath.CachedXPathAPI in project fess-crawler by codelibs.

the class HtmlXpathExtractor method getXPathAPI.

protected CachedXPathAPI getXPathAPI() {
    CachedXPathAPI cachedXPathAPI = xpathAPI.get();
    if (cachedXPathAPI == null) {
        cachedXPathAPI = new CachedXPathAPI();
        xpathAPI.set(cachedXPathAPI);
    }
    return cachedXPathAPI;
}
Also used : CachedXPathAPI(org.apache.xpath.CachedXPathAPI)

Example 3 with CachedXPathAPI

use of org.apache.xpath.CachedXPathAPI in project activemq-artemis by apache.

the class XalanXPathEvaluator method evaluate.

protected boolean evaluate(InputSource inputSource) {
    try {
        DocumentBuilder dbuilder = createDocumentBuilder();
        Document doc = dbuilder.parse(inputSource);
        // An XPath expression could return a true or false value instead of a node.
        // eval() is a better way to determine the boolean value of the exp.
        // For compliance with legacy behavior where selecting an empty node returns true,
        // selectNodeIterator is attempted in case of a failure.
        CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
        XObject result = cachedXPathAPI.eval(doc, xpath);
        if (result.bool())
            return true;
        else {
            NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath);
            return (iterator.nextNode() != null);
        }
    } catch (Throwable e) {
        return false;
    }
}
Also used : NodeIterator(org.w3c.dom.traversal.NodeIterator) DocumentBuilder(javax.xml.parsers.DocumentBuilder) CachedXPathAPI(org.apache.xpath.CachedXPathAPI) Document(org.w3c.dom.Document) XObject(org.apache.xpath.objects.XObject)

Example 4 with CachedXPathAPI

use of org.apache.xpath.CachedXPathAPI in project fess-crawler by codelibs.

the class XmlTransformer method getXPathAPI.

protected CachedXPathAPI getXPathAPI() {
    CachedXPathAPI cachedXPathAPI = xpathAPI.get();
    if (cachedXPathAPI == null) {
        cachedXPathAPI = new CachedXPathAPI();
        xpathAPI.set(cachedXPathAPI);
    }
    return cachedXPathAPI;
}
Also used : CachedXPathAPI(org.apache.xpath.CachedXPathAPI)

Aggregations

CachedXPathAPI (org.apache.xpath.CachedXPathAPI)4 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 XObject (org.apache.xpath.objects.XObject)1 Document (org.w3c.dom.Document)1 NodeIterator (org.w3c.dom.traversal.NodeIterator)1