Samina:
Please refer to the following original message from Ted Sfikas and my sample
code. You can instruct your parser to resolve the network references with
local files:
class myResolver implements EntityResolver{
public InputSource resolveEntity (String publicId, String systemId)
{
if(systemId.endsWith(".dtd")) {
try{
File infile = new File("D:\\xhtml1.dtd");
InputSource in = new InputSource(new
FileInputStream(infile));
return in;
}catch (Exception e) { }
}
}
//Later, set your parser's EntityResolver to that class
reader.setEntityResolver(new myResolver());
Thanks.
Ying
-----Original Message-----
From: Sfikas, Ted [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 18, 2001 11:44 AM
To: '[EMAIL PROTECTED]'
Subject: RE: dtd and ent over network
Ying:
I ran into this issue when I created an EJB that validated XML files
--- I call the EJB "DocumentValidatorBean".
Since EJBs are resident in Containers, no Java I/O is allowed;
therefore, DocumentValidatorBean must implement the "resolveEntity( String
pSystemID, String pPublicID )" method which is part of the "EntityResolver"
interface. The "EntityResolver" interface will be part of your Java parser
Class upon extending "DefaultHandler".
Although I am pulling out DTD's from an ORACLE database for the
validation of my input XML files, this may apply to your problem because
whenever I ran across an XML file that I did not want to have validated, I
applied logic in the "resolveEntity" method that took that into account.
Perhaps you could code the same type of thing for your problem( ie. whenever
you have a certain network DTD referenced in your DOCTYPE tag, you can
return an InputSource value that generically validates all XML files to be
good ).
Hope that helps!
-Ted Sfikas