[jdom-interest] How do specify a DTD?

Jason Hunter jhunter at acm.org
Fri Nov 15 13:25:34 PST 2002


You can use an EntityResolver, but the easier way is to pass in
something other than a stream.  A stream naturally doesn't include
location information but a File does.  So pass in the file, and then the
parser can find resolve relative paths.

-jh-

Kenneth Ellefsen wrote:
> 
> Hi.
> 
> If you have a xml file with a DOCTYPE tag specifying a dtd file, is it
> an absolute requirement that the dtd file must be in the same directory
> as the xml file?
> 
> Or is it possible at run time to tell the builder where the dtd file is
> located?
> 
> I tryed the following:
> 
> FileInputStream file = new FileInputStream(m_filename);
> m_doc = builder.build( file, "/path/to/dtdfile/file.dtd")
> 
> But is still fails with an Exception saying:
> External entity not found: "/path/to/dtdfile/file.dtd"
> 
> Tips appreciated.
> 
> --
> Mvh,
> 
> Kenneth Ellefsen                   | Tlf: (+47) 55985829
> Schlumberger Information Solutions | www.sis.slb.com
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list