/* Get "side streams" for output ready */
Document safDoc = new Document(new Element("dummy"));
/* Get the document */
Document doc = new Builder().build(new File(directory, "source.xml"));
OscarFlow oscarFlow = new OscarFlow(doc);
oscarFlow.processFull();
/* Output time! */
new Serializer(new FileOutputStream(new File(directory, "markedup.xml"))).write(oscarFlow.getInlineXML());
safDoc.getRootElement().addAttribute(new Attribute("document", directory.getName()));
new Serializer(new FileOutputStream(new File(directory, "saf.xml"))).write(oscarFlow.getSafXML());
if(oscarFlow.getGeniaSAF() != null) {
new Serializer(new FileOutputStream(new File(directory, "geniasaf.xml"))).write(oscarFlow.getGeniaSAF());
}
if(oscarFlow.getRelationXML() != null) {
new Serializer(new FileOutputStream(new File(directory, "relations.xml"))).write(oscarFlow.getRelationXML());
}
if(oscarFlow.getDataXML() != null) {
new Serializer(new FileOutputStream(new File(directory, "data.xml"))).write(oscarFlow.getDataXML());
}
/* PubXML present? Then round-trip it */
if(new File(directory, "pubxml-source.xml").exists()) {
Builder b = new Builder();
Document pubXML = b.build(new FileReader (new File(directory, "pubxml-source.xml")));
Document convDoc = b.build(new File(directory, "conv.xml"));
Document outDoc = PubXMLToSciXML.getAnnotatedPubXML(pubXML, oscarFlow.getInlineXML(), oscarFlow.getSourceXML(), convDoc);
new Serializer(new FileOutputStream(new File(directory, "pubxml-annotated.xml"))).write(outDoc);
}
/* Write out custom files, if present */
for(String filename : oscarFlow.getCustomOutputNames()) {
//InputStream is = oscarFlow.customInputStream(filename);
OutputStream os = new FileOutputStream(new File(directory, filename));
/*byte[] buffer = new byte[1024];
int i = 0;
while ((i = is.read(buffer)) != -1) {
os.write(buffer, 0, i);
}
is.close();
os.close();*/
oscarFlow.writeCustomeOutputToStream(filename, os);
os.close();
}
} catch (Exception e) {
e.printStackTrace();