Bug 1042 - DefaultReaderFactory.createReader does not honor EntityResolver SystemID
DefaultReaderFactory.createReader does not honor EntityResolver SystemID
Status: NEW
Product: Xerces-J
Classification: Unclassified
Component: Core
All All
: P3 normal
: ---
Assigned To: Xerces-J Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2001-03-20 05:59 UTC by kcritz
Modified: 2004-11-16 19:09 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description kcritz 2001-03-20 05:59:01 UTC
I am experiencing a bug when using EntityResolvers with Xerces.

In DefaultEntityHandler.startReadingFromExternalEntity, fResolver
is given the chance to resolve an InputSource.  Fair enough.

But for some reason in the call to fReaderFactory.createReader, the
original (unresolved) SystemID is passed in.  If the InputSource
created by the resolver has a null getByteStream, the original
unresolved SystemID is used to open the byte stream.

This is the only place in createReader where the systemID is used.
Doesn't it make more sense to use InputSource.getSystemID here instead?

I am trying to use my EntityResolver to redirect http:// references
to file:// references when I know that a local copy of a resource
exists.  It makes sense that I should just be able to resolve
the SystemID.  Currently, I am forced to open a ByteStream inside
the EntityResolver as a workaround.

Suggested Bug Fix: 

in DefaultReaderFactory.createReader:

change this:
        if (is == null) {

            // create url and open the stream
            URL url = new URL(systemId);
            is = url.openStream();

to this:

        if (is == null) {

            // create url and open the stream
            String urlSystemID = source.getSystemID();
            if (urlSystemID == null) urlSystemID = systemID;
            URL url = new URL(urlSystemId);
            is = url.openStream();