Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XML as resource, referencing DTD

843834Oct 9 2001 — edited Sep 25 2003
Hi 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!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 23 2003
Added on Oct 9 2001
3 comments
262 views