xerces-j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31317] New: - EntityResolver not called uniformly
Date Mon, 20 Sep 2004 19:34:43 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31317>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31317

EntityResolver not called uniformly

           Summary: EntityResolver not called uniformly
           Product: Xerces-J
           Version: 1.4.4
          Platform: All
        OS/Version: Solaris
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Core
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: justin.sands@actechnology.com


The EntityResolver set on XMLReader via XMLReader.setEntityResolver(ER) is
sometimes called and sometimes not called depending on the format of the URI for
the DTD.

I am trying to use my entity resolver to load the DTD out of the classpath.

However, my Entity Resolver, ER is not always called.  The behavior seems to
depend on the format of the URI.  If the parser thinks it knows how to resolve
the URI then it does not call the entity resolver and instead tries to use some
default resolver (which cant find the DTD since i'm loading it out of the
classpath).

For example:

These entities will try to use the default resolver
 <!DOCTYPE Modules SYSTEM "MatchingEngineEngineConfig.dtd">
 <!DOCTYPE Modules SYSTEM "justin:MatchingEngineEngineConfig.dtd">
 <!DOCTYPE Modules SYSTEM "classpath:MatchingEngineEngineConfig.dtd">

However these entities will use the custom resolver.
 <!DOCTYPE Modules SYSTEM "file://MatchingEngineEngineConfig.dtd">

I see 1 bug, and one missing feature here:
 1) The javadoc for XMLReader.setEntityResolver() needs to be updated
    to specify this behavior.  I would like to know specifically when
    the custom entity resolver will be called and when it wont.

 2) There should be some way to FORCE the parser to use the entity resolver
    no matter what.  This behavior is intimately coupled with using the 
    XMLReader.parse(InputSource) method instead of using the 
    XMLReader.parse(systemID) method.  There should be a method:

              XMLReader.parse(InputSource, EntityResolver) 

    since when you are using an input source you have some reason 
    to avoid the nomral file system mechanisms.
    (i.e. you have XML and DTDs in a database or an encrypted jar file).

---[ code snippet : getting and configuring the reader ]----------

XMLContentHandler handler = new XMLContentHandler();
XMLReader reader = null;
SAXParserFactory factory = javax.xml.parsers.SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
reader = parser.getXMLReader();
reader.setFeature("http://xml.org/sax/features/validation", true);
reader.setContentHandler(handler);
reader.setDTDHandler(handler);
reader.setEntityResolver(new ClasspathDTDResolver("com/mycorp/mypackage"));
reader.setErrorHandler(handler);

InputStream xmlInputStream=getClass().getClassLoader().getResourceAsStream(xmlFile);
reader.parse(new InputSource(xmlInputStream));

------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Mime
View raw message