Search in sources :

Example 1 with ContentReceiver

use of org.exist.contentextraction.ContentReceiver in project exist by eXist-db.

the class ContentFunctions method streamContent.

private Sequence streamContent(ContentExtraction ce, BinaryValue binary, Sequence pathSeq, FunctionReference ref, Map<String, String> mappings, Sequence data) throws XPathException {
    NodePath[] paths = new NodePath[pathSeq.getItemCount()];
    int i = 0;
    for (SequenceIterator iter = pathSeq.iterate(); iter.hasNext(); i++) {
        String path = iter.nextItem().getStringValue();
        paths[i] = new NodePath(mappings, path, false);
    }
    ContentReceiver receiver = new ContentReceiver(context, paths, ref, data);
    try {
        ce.extractContentAndMetadata(binary, receiver);
    } catch (IOException | SAXException | ContentExtractionException ex) {
        LOG.error(ex.getMessage(), ex);
        throw new XPathException(this, ex.getMessage(), ex);
    }
    return receiver.getResult();
}
Also used : SequenceIterator(org.exist.xquery.value.SequenceIterator) XPathException(org.exist.xquery.XPathException) IOException(java.io.IOException) ContentReceiver(org.exist.contentextraction.ContentReceiver) ContentExtractionException(org.exist.contentextraction.ContentExtractionException) NodePath(org.exist.storage.NodePath) SAXException(org.xml.sax.SAXException)

Aggregations

IOException (java.io.IOException)1 ContentExtractionException (org.exist.contentextraction.ContentExtractionException)1 ContentReceiver (org.exist.contentextraction.ContentReceiver)1 NodePath (org.exist.storage.NodePath)1 XPathException (org.exist.xquery.XPathException)1 SequenceIterator (org.exist.xquery.value.SequenceIterator)1 SAXException (org.xml.sax.SAXException)1