classpathx-xml
[Top][All Lists]
Advanced

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

Re: [Classpathx-xml] Unwanted SAXParseException


From: David Brownell
Subject: Re: [Classpathx-xml] Unwanted SAXParseException
Date: Sat, 18 Oct 2003 08:21:35 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225

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!

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.

That's part of the reason why the SAX spec has long said specifically:
"An InputSource object belongs to the application: the SAX parser
shall never modify it in any way...".  (Which is what your patch
makes it do...)

The right fix in this case is to your Resolver implementation,
not any parser, since any parser change is likely to break some
other application.

- Dave



      }
      catch (Exception e) {
          return null;
      }
  }
}








reply via email to

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