Hi,
I get different results when trying to implement an Entity-resolver
depending on the construction of an InputSource.
1) When implementing the resolver like
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
if (publicId != null && publicId.equals(DTD_PUBLICID)) {
InputSource src = new
InputSource(getClass().getResource(DTD_NAME).toString());
src.setPublicId(publicId);
return src;
}
else
return null;
}
the entity-resolver doesn't work.
2) When implementing the resolver like
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
if (publicId != null && publicId.equals(DTD_PUBLICID)) {
InputSource src = new InputSource();
src.setPublicId(publicId);
InputStream is = getClass().getResourceAsStream(DTD_NAME);
src.setByteStream(is);
InputStreamReader isr = new InputStreamReader(is);
src.setCharacterStream(isr);
return src;
}
else
return null;
}
everything works fine.
I'd expect, that both constructs return the same InputSource (since
getRessource() returns a full qualified URI), but they obviously dont. I'm
not sure whether this is an expected behaviour or a bug.
Armin
P.S.
Please note that getRessource() returns a full qualified URI like URI
file:/c:/test.dtd. It doesn't look like file:///c:/test.dtd (there is only
one (1) slash after file:)
I'm using JDK1.2.2 from SUN under NT and the latest available
Xerces-Implementation from xml.apache.org/dist.