[jdom-interest] How to read a DTD as a resource file?

stephan.segschneider at snellwilcox.com stephan.segschneider at snellwilcox.com
Fri May 18 00:51:15 PDT 2001


Hi all

I need to pack my DTD inside my application and parse a XML file validating
against this DTD.

The following code works fine with JDOM:

   InputStream xmlIS = App.class.getResourceAsStream(xmlFileName);
   builder.setValidation(validate);
   builder.setErrorHandler(errorHandler);
   // Build the JDOM Document
   doc = builder.build(xmlIS, dtdURL.toString());

this is OK if the DTD is an external file, but what do I need to do if the DTD
is packed inside my applications jar file. The AElfred parser for example allows
somthing like this:

InputStream xmlIS = Appl.class.getResourceAsStream(xmlFileName);
InputStream dtdIS = Appl.class.getResourceAsStream(dtdFileName);
InputStreamReader xmlStream = new InputStreamReader(is);
parser.parse( dtdIS, null, xmlIS);

Any help would be appreciated.

 Cheers,
               Stephan

 
-----------------------------------------------------------------
  Stephan Segschneider
  Durford Mill  
  Voice : +44 (0)1730 818 747
  EMail : stephan.segschneider at snellwilcox.com  (office)
  EMail : stephan.segschneider at cwcom.net  (private)
-----------------------------------------------------------------




More information about the jdom-interest mailing list