Hello,

I use the parser in non-validating mode and want it to continue after
an IOException is thrown during attempt to open an external entity (
check for its reachability). Parser should recover from such state in 
non-validating mode even if scanning of external entities is enabled.

An attached patch fixes the behaviour by reporting a warning.

It means that parser throws IOException (that moves parsing to
unrecoverable state) only if it can not fetch data from already
opened entity stream. 

Does it make sense? I hope so. 
Is there a better solution? I do not know.
 
  Cc.

-- 
<address>
<a href="mailto:[EMAIL PROTECTED]";>Petr Kuzel</a>, Sun Microsystems
: <a href="http://www.sun.com/forte/ffj/ie/";>Forte Tools</a>
: XML and <a href="http://jini.netbeans.org/";>Jini</a> modules</address>
Index: src/org/apache/xerces/impl/msg/XMLMessages.properties
===================================================================
RCS file: 
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/msg/Attic/XMLMessages.properties,v
retrieving revision 1.1.2.17
diff -u -b -r1.1.2.17 XMLMessages.properties
--- src/org/apache/xerces/impl/msg/XMLMessages.properties       2000/12/04 23:49:56    
 1.1.2.17
+++ src/org/apache/xerces/impl/msg/XMLMessages.properties       2001/06/04 14:08:01
@@ -244,6 +244,8 @@
 # 4.3.3 Character Encoding in Entities
         EncodingNotSupported = The encoding \"{0}\" is not supported.
         EncodingRequired = A parsed entity not encoded in either UTF-8 or UTF-16 must 
contain an encoding declaration.
+# ?.? 
+        SkippingUnreachable = Skipping unreachable \"{0}\" entity reference.
        
 # Namespaces support
 # 4. Using Qualified Names
Index: src/org/apache/xerces/impl/XMLEntityManager.java
===================================================================
RCS file: 
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLEntityManager.java,v
retrieving revision 1.1.2.77
diff -u -b -r1.1.2.77 XMLEntityManager.java
--- src/org/apache/xerces/impl/XMLEntityManager.java    2001/05/18 18:02:33     
1.1.2.77
+++ src/org/apache/xerces/impl/XMLEntityManager.java    2001/06/04 14:07:07
@@ -92,6 +92,7 @@
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXNotSupportedException;
+import java.io.ByteArrayInputStream;
 
 /**
  * The entity manager handles the registration of general and parameter
@@ -954,7 +955,19 @@
                     expandedSystemId = expandSystemId(systemId, baseSystemId);
                     xmlInputSource.setExpandedSystemId(expandedSystemId);
                 }
+                 
+                // do not propagate IOException if in wellformess mode.
+                
+                try {
                 stream = new URL(expandedSystemId).openStream();
+                } catch (IOException ex) {
+                    if (fValidation) throw ex;
+                    fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
+                                               "SkippingUnreachable",
+                                               new Object[] {name}, 
+                                               fErrorReporter.SEVERITY_WARNING);
+                    stream = new ByteArrayInputStream(new byte[0]);  // simulate it 
+as empty
+                }                                
             }
                 
             // perform auto-detect of encoding

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to