[kaffe] Re: [Classpathx-xml] Unwanted SAXParseException

David Brownell david-b@pacbell.net
Sat Oct 18 23:10:02 PDT 2003


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;
>       }
>   }
> }








More information about the kaffe mailing list