int status = 0;
if (!outputXml) {
// simple list of files
for (File file2 : ftp)
{
status |= runSimple(new FileDataSource(file2));
}
System.exit(status);
} else {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
XmlResultParser xrp = new XmlResultParser();
if (isGroup) {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element root = document.createElement("preflights");
document.appendChild(root);
root.setAttribute("count", String.format("%d", ftp.size()));
for (File file : ftp)
{
Element result = xrp.validate(document,new FileDataSource(file));
root.appendChild(result);
}
transformer.transform(new DOMSource(document), new StreamResult(new File(args[posFile]+".preflight.xml")));
} else {
// isBatch
for (File file : ftp)
{
Element result = xrp.validate(new FileDataSource(file));
Document document = result.getOwnerDocument();
document.appendChild(result);
transformer.transform(new DOMSource(document), new StreamResult(new File(file.getAbsolutePath()+".preflight.xml")));
}
}
}
} else {
// only one file
FileDataSource fd = new FileDataSource(args[posFile]);
if (!outputXml) {
// simple validation
System.exit(runSimple(fd));
} else {
// generate xml output