+\r
+ public static XmlObject parseXmlFile(File xmlFile) throws IOException, XmlException {\r
+ Collection errors = new ArrayList(); \r
+ XmlOptions opt = new XmlOptions();\r
+\r
+ opt.setLoadLineNumbers();\r
+ opt.setLoadMessageDigest();\r
+ opt.setErrorListener(errors);\r
+\r
+ XmlObject doc = XmlObject.Factory.parse(xmlFile, opt);\r
+ //\r
+ // Validate File if they accord with XML Schema\r
+ //\r
+ if (!doc.validate(opt)){\r
+ StringBuilder errorMessage = new StringBuilder(1024);\r
+ for (Iterator it = errors.iterator(); it.hasNext(); ) {\r
+ errorMessage.append(it.next());\r
+ errorMessage.append("\n");\r
+ }\r
+ throw new XmlException(errorMessage.toString());\r
+ }\r
+\r
+ return doc;\r
+ }\r