classpathx-xml
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Classpathx-xml] Unwanted SAXParseException


From: Ito Kazumitsu
Subject: Re: [Classpathx-xml] Unwanted SAXParseException
Date: Sun, 19 Oct 2003 10:14:05 +0900
User-agent: EMH/1.10.0 SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.2 (i386-unknown-freebsd4.7) MULE/5.0 (SAKAKI)

>>>>> ":" == David Brownell <address@hidden> writes:

:> Ito Kazumitsu wrote:
>> private static class MyResolver implements EntityResolver {
>> public InputSource resolveEntity (String publicId, String systemId) {
>> try {
>> return new InputSource((new URL(systemId)).openStream());

:> This is the bug right here ... you're creating an InputSource
:> without a System ID, which is why you get a later complaint
:> about an InputSource that's missing such an ID!

Yes, I knew about it and deliberately made such an incomplete
program.

The problem is that Sun's JAXP or Xerces does not throw
an exception about this.

:> It's unhealthy to have infrastructure guessing about such
:> things, since it doesn't really have the facts to guess right.
:> For example, the resolver is allowed to change the system ID
:> based on the public ID, in which case the (local) system ID
:> would clearly be wrong.

I think so, too.

As for the patch to gnu/xml/aelfred2/SAXDriver.java,  I think
it should be removed.

Then occurs another question.  Is it correct that 
gnu/xml/aelfred2/XmlParser.java does this in pushURL()?

            systemId = source.getSystemId ();
            if (systemId == null) {
                handler.warn ("missing system ID, using " + ids [1]);
                systemId = ids [1];
            }

Giving the warning of "missing system ID" should be postponed
until the system ID is really needed.

And here is my patch:

bash-2.05b$ diff -u gnu/xml/aelfred2/XmlParser.java.orig 
gnu/xml/aelfred2/XmlParser.java
--- gnu/xml/aelfred2/XmlParser.java.orig        Sun Sep 14 07:32:02 2003
+++ gnu/xml/aelfred2/XmlParser.java     Sun Oct 19 10:07:50 2003
@@ -3424,6 +3424,7 @@
     ) throws SAXException, IOException
     {
        boolean         ignoreEncoding;
+       boolean         systemIdGuessed = false;
        String          systemId;
        InputSource     source;
 
@@ -3450,8 +3451,8 @@
            // we might be using alternate IDs/encoding
            systemId = source.getSystemId ();
            if (systemId == null) {
-               handler.warn ("missing system ID, using " + ids [1]);
                systemId = ids [1];
+               systemIdGuessed = true;
            }
        } else {
            // "[document]", or "[dtd]" via getExternalSubset()
@@ -3480,8 +3481,11 @@
            } catch (IOException e) {
                stream = source.getByteStream ();
            }
-       } else if (systemId == null)
+       } else if (systemId == null) {
            error ("InputSource has no URI!");
+       } else if (systemIdGuessed) {
+           handler.warn ("missing system ID, using " + systemId);
+       }
        scratch.setCharacterStream (null);
        scratch.setByteStream (null);
        scratch.setEncoding (null);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]