Fail the XML parse if validation required and the Schema build failed
authorgilbert <gilbert@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 12 Jul 2005 14:42:34 +0000 (14:42 +0000)
committergilbert <gilbert@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 12 Jul 2005 14:42:34 +0000 (14:42 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@1725 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/xml/Parser.java

index f7b3073..6b5c1fa 100644 (file)
@@ -177,11 +177,14 @@ public class Parser {
      * @param validate If true, use Schema. Otherwise, its raw XML.
      * @return A DOM 3 tree
      */
-    public static Document loadDom(InputSource ins, boolean validate) throws SAMLException, SAXException, IOException {
+    public static Document loadDom(InputSource ins, boolean validate) 
+        throws SAMLException, SAXException, IOException {
 
                Document doc = null;
                log.debug("Loading XML from (" + ins.getSystemId() + ")" + (validate ? " with Schema validation" : ""));
                if (validate) {
+            if (schema==null) 
+                throw new SAXException("Cannot validate XML because of invalid Schemas");
                        doc = org.opensaml.XML.parserPool.parse(ins, schema);
                } else {
                        doc = org.opensaml.XML.parserPool.parse(ins, null);