private static Document processFile(String filename, String mode) throws Exception {
// First make sure the properties file is loaded...
Oscar3Props.getInstance();
Document doc;
PubXMLToSciXML ptsx = null;
if(mode.equals("Process") || mode.equals("SAF") || mode.equals("Data")) {
System.out.println("Loading file...");
doc = ToSciXML.fileToSciXML(new File(filename));
} else if(mode.equals("RoundTrip")) {
ptsx = new PubXMLToSciXML(new Builder().build(new File(filename)));
doc = ptsx.getSciXML();
} else {
throw new Error("Mode not recognised");
}
OscarFlow oscarFlow = new OscarFlow(doc);
if(mode.equals("Process")) {
oscarFlow.processLite();
return oscarFlow.getInlineXML();
} else if(mode.equals("SAF")) {
oscarFlow.processToSAF();
return oscarFlow.getSafXML();
} else if(mode.equals("Data")) {
oscarFlow.parseData();
return oscarFlow.getDataXML();
} else if(mode.equals("RoundTrip")) {
oscarFlow.processLite();
ptsx.setSciXMLDoc(oscarFlow.getInlineXML());
return ptsx.getAnnotatedPubXML();
}
return null;
}