Search in sources :

Example 1 with SAXWriter

use of org.dom4j.io.SAXWriter in project webanno by webanno.

the class TeiReader method getNext.

@Override
public void getNext(CAS aCAS) throws IOException, CollectionException {
    initCas(aCAS, currentResource);
    InputStream is = null;
    try {
        JCas jcas = aCAS.getJCas();
        // Create handler
        Handler handler = newSaxHandler();
        handler.setJCas(jcas);
        handler.setLogger(getLogger());
        // Parse TEI text
        SAXWriter writer = new SAXWriter(handler);
        writer.write(currentTeiElement);
        handler.endDocument();
    } catch (CASException e) {
        throw new CollectionException(e);
    } catch (SAXException e) {
        throw new IOException(e);
    } catch (Exception e) {
        throw new IOException("This is not a valid WebAnno CPH TEI file");
    } finally {
        closeQuietly(is);
    }
    // Move currentTeiElement to the next text
    nextTeiElement();
}
Also used : SAXWriter(org.dom4j.io.SAXWriter) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) CollectionException(org.apache.uima.collection.CollectionException) JCas(org.apache.uima.jcas.JCas) DefaultHandler(org.xml.sax.helpers.DefaultHandler) CASException(org.apache.uima.cas.CASException) IOException(java.io.IOException) JaxenException(org.jaxen.JaxenException) ResourceInitializationException(org.apache.uima.resource.ResourceInitializationException) DocumentException(org.dom4j.DocumentException) CASException(org.apache.uima.cas.CASException) CollectionException(org.apache.uima.collection.CollectionException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) SAXException(org.xml.sax.SAXException)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 CASException (org.apache.uima.cas.CASException)1 CollectionException (org.apache.uima.collection.CollectionException)1 JCas (org.apache.uima.jcas.JCas)1 ResourceInitializationException (org.apache.uima.resource.ResourceInitializationException)1 DocumentException (org.dom4j.DocumentException)1 SAXWriter (org.dom4j.io.SAXWriter)1 JaxenException (org.jaxen.JaxenException)1 SAXException (org.xml.sax.SAXException)1 DefaultHandler (org.xml.sax.helpers.DefaultHandler)1