Bug 1042 - DefaultReaderFactory.createReader does not honor EntityResolver SystemID
Summary: DefaultReaderFactory.createReader does not honor EntityResolver SystemID
Status: NEW
Alias: None
Product: Xerces-J
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.2.3
Hardware: All All
: P3 normal
Target Milestone: ---
Assignee: Xerces-J Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-03-20 05:59 UTC by kcritz
Modified: 2004-11-16 19:09 UTC (History)
0 users



Attachments

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