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();
}
Aggregations