out.close();
return;
}
/* Process the document */
OscarFlow oscarFlow = new OscarFlow(plainDoc);
if(request.getParameter("flowcommand") != null &&
request.getParameter("flowcommand").trim().length() > 0) {
oscarFlow.runFlow(request.getParameter("flowcommand"));
} else if(outputMode.equals("data")) {
oscarFlow.parseData();
} else {
oscarFlow.processLite();
}
if(outputMode.equals("default") && request.getParameter("flowcommand") != null &&
!request.getParameter("flowcommand").toLowerCase().contains("inline")) {
outputMode = "saf";
}
if(outputMode.equalsIgnoreCase("custom")) {
String name = request.getParameter("name");
if(name.endsWith(".xml")) {
response.setContentType("application/xml");
response.setCharacterEncoding("UTF-8");
} else if(name.endsWith(".htm") || name.endsWith(".html")) {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
} else {
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
}
} else {
response.setContentType("application/xml");
response.setCharacterEncoding("UTF-8");
}
OutputStream out = response.getOutputStream();
if(outputMode.equalsIgnoreCase("saf")) {
new Serializer(out).write(oscarFlow.getSafXML());
} else if(outputMode.equalsIgnoreCase("data")) {
new Serializer(out).write(oscarFlow.getDataXML());
} else if(outputMode.equalsIgnoreCase("genia")) {
new Serializer(out).write(oscarFlow.getGeniaSAF());
} else if(outputMode.equalsIgnoreCase("relation")) {
new Serializer(out).write(oscarFlow.getRelationXML());
} else if(outputMode.equalsIgnoreCase("custom")) {
String name = request.getParameter("name");
oscarFlow.writeCustomeOutputToStream(name, out);
} else {
// default to markedup
doc = SciXMLDocument.makeFromDoc(oscarFlow.getInlineXML());
doc.addServerProcessingInstructions();
new Serializer(out).write(doc);
out.close();
}