Search in sources :

Example 1 with TypeTest

use of org.exist.xquery.TypeTest in project exist by eXist-db.

the class EXistResult method add.

@Override
public void add(final HttpResponse response) throws HttpClientException {
    final EXistTreeBuilder builder = new EXistTreeBuilder(context);
    response.outputResponseElement(builder);
    final DocumentImpl doc = builder.close();
    try {
        // we add the root *element* to the result sequence
        final NodeTest kind = new TypeTest(Type.ELEMENT);
        // add the original items after
        if (result.isEmpty()) {
            doc.selectChildren(kind, result);
        } else {
            final ValueSequence newResult = new ValueSequence();
            doc.selectChildren(kind, newResult);
            newResult.addAll(result);
            result = newResult;
        }
    } catch (final XPathException xpe) {
        throw new HttpClientException("Unable to add HttpResponse to result:" + xpe.getMessage(), xpe);
    }
}
Also used : HttpClientException(org.expath.httpclient.HttpClientException) XPathException(org.exist.xquery.XPathException) TypeTest(org.exist.xquery.TypeTest) DocumentImpl(org.exist.dom.memtree.DocumentImpl) NodeTest(org.exist.xquery.NodeTest)

Aggregations

DocumentImpl (org.exist.dom.memtree.DocumentImpl)1 NodeTest (org.exist.xquery.NodeTest)1 TypeTest (org.exist.xquery.TypeTest)1 XPathException (org.exist.xquery.XPathException)1 HttpClientException (org.expath.httpclient.HttpClientException)1