XML as resource, referencing DTD
843834Oct 9 2001 — edited Sep 25 2003Hi everyone.
I have a set of XML files based on a DTD, and am getting the XML data via java.lang.class's getResourceAsStream().
Each XML file references the DTD with a DOCTYPE SYSTEM, with a relative path (the DTD is in the same directory as the XML files).
I can get the input stream with the XML data just fine, but the parser cannot find the DTD. It always looks for it relative to the working directory, not relative to the XML file itself.
This is really strange since, if you get a FileInputStream having the XML data, the reference is found properly.
The ultimate goal is to package the XML files along with the DTD in a jar file along with the Java classes -- that's why I want to get them as resources.
So, I guess my question is:
Is there anything in the XML processing API (I am SAX-parsing) that will allow me to read an XML file as a jar resource, and properly reference a DTD that also exists as a resource?
Thanks!