You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2009/04/19 18:26:25 UTC

svn commit: r766481 - /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java

Author: mrglavas
Date: Sun Apr 19 16:26:25 2009
New Revision: 766481

URL: http://svn.apache.org/viewvc?rev=766481&view=rev
Log:
JIRA Issue #1124:
http://issues.apache.org/jira/browse/XERCESJ-1124

If an IOException was thrown from an attempt to read a schema document
pass this exception on to the error reporter. Previously we were swallowing
this exception and only reporting a vague error message. Applications can
now get more information by querying SAXException.getException().

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java?rev=766481&r1=766480&r2=766481&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java Sun Apr 19 16:26:25 2009
@@ -1800,6 +1800,7 @@
             boolean mustResolve, short referType, Element referElement) {
         
         boolean hasInput = true;
+        IOException exception = null;
         // contents of this method will depend on the system we adopt for entity resolution--i.e., XMLEntityHandler, EntityHandler, etc.
         Element schemaElement = null;
         try {
@@ -1839,8 +1840,9 @@
             }
         }
         catch (IOException ex) {
+            exception = ex;
         }
-        return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement);
+        return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
     } // getSchemaDocument(String, XMLInputSource, boolean, short, Element): Element
     
     /**
@@ -1857,6 +1859,7 @@
         XMLReader parser = schemaSource.getXMLReader();
         InputSource inputSource = schemaSource.getInputSource();
         boolean hasInput = true;
+        IOException exception = null;
         Element schemaElement = null;
         try {
             if (inputSource != null &&
@@ -1943,8 +1946,9 @@
             throw SAX2XNIUtil.createXNIException0(se);
         }
         catch (IOException ioe) {
+            exception = ioe;
         }
-        return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement);
+        return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
     } // getSchemaDocument(String, SAXInputSource, boolean, short, Element): Element
     
     /**
@@ -1959,6 +1963,7 @@
     private Element getSchemaDocument(String schemaNamespace, DOMInputSource schemaSource,
             boolean mustResolve, short referType, Element referElement) {
         boolean hasInput = true;
+        IOException exception = null;
         Element schemaElement = null;
         Element schemaRootElement = null;
         
@@ -2006,8 +2011,9 @@
             }
         }
         catch (IOException ioe) {
+            exception = ioe;
         }
-        return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement);
+        return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
     } // getSchemaDocument(String, DOMInputSource, boolean, short, Element): Element
     
     /**
@@ -2021,6 +2027,7 @@
      */
     private Element getSchemaDocument(String schemaNamespace, StAXInputSource schemaSource,
             boolean mustResolve, short referType, Element referElement) {
+        IOException exception = null;
         Element schemaElement = null;
         try {
             final boolean consumeRemainingContent = schemaSource.shouldConsumeRemainingContent();
@@ -2082,8 +2089,9 @@
             throw new XMLParseException(slw, e.getMessage(), e);
         }
         catch (IOException e) {
+            exception = e;
         }
-        return getSchemaDocument1(mustResolve, true, schemaSource, referElement);
+        return getSchemaDocument1(mustResolve, true, schemaSource, referElement, exception);
     } // getSchemaDocument(String, StAXInputSource, boolean, short, Element): Element
     
     /**
@@ -2107,25 +2115,25 @@
      * Error handling code shared between the various getSchemaDocument() methods.
      */
     private Element getSchemaDocument1(boolean mustResolve, boolean hasInput, 
-            XMLInputSource schemaSource, Element referElement) {
+            XMLInputSource schemaSource, Element referElement, IOException ioe) {
         // either an error occured (exception), or empty input source was
         // returned, we need to report an error or a warning
         if (mustResolve) {
             if (hasInput) {
                 reportSchemaError("schema_reference.4",
                         new Object[]{schemaSource.getSystemId()},
-                        referElement);
+                        referElement, ioe);
             }
             else {
                 reportSchemaError("schema_reference.4",
                         new Object[]{schemaSource == null ? "" : schemaSource.getSystemId()},
-                        referElement);
+                        referElement, ioe);
             }
         }
         else if (hasInput) {
             reportSchemaWarning("schema_reference.4",
                     new Object[]{schemaSource.getSystemId()},
-                    referElement);
+                    referElement, ioe);
         }
         
         fLastSchemaWasDuplicate = false;
@@ -2821,24 +2829,32 @@
     }
     
     void reportSchemaError(String key, Object[] args, Element ele) {
+        reportSchemaError(key, args, ele, null);
+    }
+    
+    void reportSchemaError(String key, Object[] args, Element ele, Exception exception) {
         if (element2Locator(ele, xl)) {
             fErrorReporter.reportError(xl, XSMessageFormatter.SCHEMA_DOMAIN,
-                    key, args, XMLErrorReporter.SEVERITY_ERROR);
+                    key, args, XMLErrorReporter.SEVERITY_ERROR, exception);
         }
         else {
             fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
-                    key, args, XMLErrorReporter.SEVERITY_ERROR);
+                    key, args, XMLErrorReporter.SEVERITY_ERROR, exception);
         }
     }
     
     void reportSchemaWarning(String key, Object[] args, Element ele) {
+        reportSchemaWarning(key, args, ele, null);
+    }
+    
+    void reportSchemaWarning(String key, Object[] args, Element ele, Exception exception) {
         if (element2Locator(ele, xl)) {
             fErrorReporter.reportError(xl, XSMessageFormatter.SCHEMA_DOMAIN,
-                    key, args, XMLErrorReporter.SEVERITY_WARNING);
+                    key, args, XMLErrorReporter.SEVERITY_WARNING, exception);
         }
         else {
             fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
-                    key, args, XMLErrorReporter.SEVERITY_WARNING);
+                    key, args, XMLErrorReporter.SEVERITY_WARNING, exception);
         }
     }
     



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org