Index: src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java
===================================================================
--- src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java	(revision 1457209)
+++ src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java	(working copy)
@@ -21,12 +21,30 @@
 
 package org.apache.pdfbox.preflight;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.activation.DataSource;
 import javax.activation.FileDataSource;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.pdfbox.Version;
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 import org.apache.pdfbox.preflight.exception.SyntaxValidationException;
 import org.apache.pdfbox.preflight.parser.PreflightParser;
+import org.apache.pdfbox.preflight.parser.XmlResultParser;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 /**
  * This class is a simple main class used to check the validity of a pdf file.
@@ -43,13 +61,95 @@
     {
         if (args.length == 0)
         {
-            System.out.println("Usage : java org.apache.pdfbox.preflight.Validator_A1b <file path>");
-            System.out.println("Version : " + Version.getVersion());
+            usage();
             System.exit(1);
         }
 
+        // is output xml ?
+        int posFile = 0;
+        boolean outputXml = "xml".equals(args[posFile]);
+        posFile += outputXml?1:0;
+        // list
+        boolean isGroup = "group".equals(args[posFile]);
+        posFile += isGroup?1:0;
+        // list
+        boolean isBatch = "batch".equals(args[posFile]);
+        posFile += isBatch?1:0;
+        
+        if (isGroup||isBatch) {
+            // prepare the list
+            List<File> ftp = listFiles(args[posFile]);
+            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
+                XmlResultParser xrp = new XmlResultParser();
+                Element result = xrp.validate(fd);
+                Document document = result.getOwnerDocument();
+                document.appendChild(result);
+                Transformer transformer = TransformerFactory.newInstance().newTransformer();
+                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+                transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+                transformer.transform(new DOMSource(document), new StreamResult(System.out));
+            }
+        }
+        
+    }
+    
+    private static void usage () {
+        System.out.println("Usage : java org.apache.pdfbox.preflight.Validator_A1b [xml] [mode] <file path>");
+        System.out.println();
+        System.out.println(" * xml : if set, generate xml output");
+        System.out.println(" * mode : if set, <file path> must be a file containing PDF to parse, can have 2 values");
+        System.out.println("       batch : for each file of the list and xml file is generated");
+        System.out.println("       group : generate an xml result for all the file of the list.");
+        System.out.println("Version : " + Version.getVersion());
+    }
+    
+    private static int runSimple (DataSource fd) throws Exception {
         ValidationResult result = null;
-        FileDataSource fd = new FileDataSource(args[0]);
         PreflightParser parser = new PreflightParser(fd);
         try
         {
@@ -66,18 +166,36 @@
 
         if (result.isValid())
         {
-            System.out.println("The file " + args[0] + " is a valid PDF/A-1b file");
-            System.exit(0);
+            System.out.println("The file " + fd.getName() + " is a valid PDF/A-1b file");
+            System.out.println();
+            return 0;
         }
         else
         {
-            System.out.println("The file" + args[0] + " is not valid, error(s) :");
+            System.out.println("The file" + fd.getName() + " is not valid, error(s) :");
             for (ValidationError error : result.getErrorsList())
             {
                 System.out.println(error.getErrorCode() + " : " + error.getDetails());
             }
-
-            System.exit(-1);
+            System.out.println();
+            return -1;
+        }
+       
+    }
+    
+    
+    private static List<File> listFiles (String path) throws IOException {
+        List<File> files = new ArrayList<File>();
+        File f = new File(path);
+        FileReader fr = new FileReader(f);
+        BufferedReader buf = new BufferedReader(fr);
+        while (buf.ready()) {
+            File fn = new File(buf.readLine());
+            if (fn.exists()) {
+                files.add(fn);
+            } // else warn ?
         }
+        IOUtils.closeQuietly(buf);
+        return files;
     }
 }
Index: src/main/java/org/apache/pdfbox/preflight/parser/XmlResultParser.java
===================================================================
--- src/main/java/org/apache/pdfbox/preflight/parser/XmlResultParser.java	(revision 0)
+++ src/main/java/org/apache/pdfbox/preflight/parser/XmlResultParser.java	(working copy)
@@ -0,0 +1,148 @@
+package org.apache.pdfbox.preflight.parser;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.activation.DataSource;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.pdfbox.preflight.PreflightDocument;
+import org.apache.pdfbox.preflight.ValidationResult;
+import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
+import org.apache.pdfbox.preflight.exception.SyntaxValidationException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class XmlResultParser
+{
+
+
+    public Element validate (DataSource source) throws IOException {
+        try {
+            Document rdocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+            return validate(rdocument,source);
+        } catch (ParserConfigurationException e) {
+            throw new IOException("Failed to init document builder", e);
+        }
+    }
+
+
+    public Element validate (Document rdocument, DataSource source) throws IOException {
+        String pdfType = null;
+        ValidationResult result = null;
+        long before = System.currentTimeMillis();
+        try {
+            PreflightParser parser = new PreflightParser(source);
+            try
+            {
+                parser.parse();
+                PreflightDocument document = parser.getPreflightDocument();
+                document.validate();
+                pdfType = document.getSpecification().getFname();
+                result = document.getResult();
+                document.close();
+            }
+            catch (SyntaxValidationException e)
+            {
+                result = e.getResult();
+            }
+        } 
+        catch(Exception e) 
+        {
+            long after = System.currentTimeMillis();
+            return generateFailureResponse(rdocument, source.getName(), after-before, pdfType, e);
+        }
+
+        long after = System.currentTimeMillis();
+        if (result.isValid()) {
+            Element preflight = generateResponseSkeleton(rdocument, source.getName(), after-before);
+            // valid ?
+            Element valid = rdocument.createElement("isValid");
+            valid.setAttribute("type", pdfType);
+            valid.setTextContent("true");
+            preflight.appendChild(valid);
+            return preflight;
+        } else {
+            Element preflight = generateResponseSkeleton(rdocument, source.getName(), after-before);
+            // valid ?
+            Element valid = rdocument.createElement("isValid");
+            valid.setAttribute("type", pdfType);
+            valid.setTextContent("false");
+            preflight.appendChild(valid);
+            // errors list
+            List<ValidationError> cleaned = cleanErrorList(result.getErrorsList());
+            Element errors = rdocument.createElement("errors");
+            errors.setAttribute("count", String.format("%d", cleaned.size()));
+            preflight.appendChild(errors);
+            int i=0;
+            for (ValidationError validationError : cleaned)
+            {
+                Element error = rdocument.createElement("error");
+                error.setAttribute("count", String.format("%d",i++));
+                Element code = rdocument.createElement("code");
+                code.setTextContent(validationError.getErrorCode());
+                error.appendChild(code);
+                Element detail = rdocument.createElement("details");
+                detail.setTextContent(validationError.getDetails());
+                error.appendChild(detail);
+                errors.appendChild(error);
+            }
+            return preflight;
+        }
+
+    }
+
+    private List<ValidationError> cleanErrorList (List<ValidationError> errors) {
+        List<ValidationError> cleaned = new ArrayList<ValidationResult.ValidationError>(errors.size());
+        List<String> already = new ArrayList<String>(errors.size());
+        for (ValidationError validationError : errors)
+        {
+            if (!already.contains(validationError.getErrorCode())) {
+                // first time
+                cleaned.add(validationError);
+                already.add(validationError.getErrorCode());
+            } // else already found
+        }
+        return cleaned;
+    }
+
+    private Element generateFailureResponse (Document rdocument, String name,long duration, String pdfType, Exception e) {
+        Element preflight = generateResponseSkeleton(rdocument, name, duration);
+        // valid ?
+        Element valid = rdocument.createElement("isValid");
+        valid.setAttribute("type", pdfType);
+        valid.setTextContent("false");
+        preflight.appendChild(valid);
+        // exception 
+        Element exception = rdocument.createElement("exceptionThrown");
+        Element message = rdocument.createElement("message");
+        message.setTextContent(e.getMessage());
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        e.printStackTrace(pw);
+        pw.close();
+        Element stack = rdocument.createElement("stackTrace");
+        stack.setTextContent(sw.toString());
+        exception.appendChild(message);
+        exception.appendChild(stack);
+        preflight.appendChild(exception);
+        return preflight;
+    }
+
+    private Element generateResponseSkeleton (Document rdocument, String name, long duration) {
+        Element preflight = rdocument.createElement("preflight");
+        preflight.setAttribute("name", name);
+        // duration
+        Element eduration = rdocument.createElement("executionTimeMS");
+        eduration.setTextContent(String.format("%d", duration));
+        preflight.appendChild(eduration);
+        // return skeleton
+        return preflight;
+    }
+
+
+}
