commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p>
Subject [digester] problem loading the dtd when using getResourceAsStream()
Date Tue, 20 May 2003 20:39:16 GMT

My XML file has a DTD declaration like this:

<!DOCTYPE help SYSTEM "help.dtd">

The DTD file is in the same directory as the XML file, which works when 
opening the file in an XML editor. But I am loading the file in my 
application (a web application) as a resource, like this:

InputStream in = getClass().getResourceAsStream(helpFileName);

Digester d = new Digester();
// ...

The error I get at runtime is:
org.xml.sax.SAXParseException: Relative URI "help.dtd"; can not be 
resolved without a base URI.

I still get this error if I do setValidating(false), which I find odd.

So my question is, what should I use for the DTD URI? Or how should I 
be doing this differently? I can't specify an absolute URI starting 
with a '/' because I don't know where the app will be deployed on the 
sytem (which is why I'm using getResourceAsStream()). The DTD file is 
available as a resource, but how can I tell the digester where to find 

I think I could put the DTD on a web server somewhere and use a URI 
starting with "http://", but there are many reasons why I don't want to 
do that, so hopefully somebody will enlighten me with a better answer!


View raw message