See comments/code below... -----Original Message----- From: Wong Kok Wai <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]> Date: 29 February 2000 3:58 Subject: Re: Validating against a different DTD
>You can write a class that implements org.xml.sax.EntityResolver and returns >an InputSource that "points" to your local DTD copies. Pass this object to >the SAX parser using setEntityResolver. > >Elliotte Rusty Harold wrote: > >> Is there any way in Xerces I can easily choose a specific DTD/schema to >> validate documents against from within the parser? >> > As an example of Wong Kok Wai's suggestion: class LocalDriveEntityResolver implements EntityResolver { public InputSource resolveEntity (String publicId, String systemId) { // return a special input source try { return new InputSource(new FileInputStream("x:\" + dToDirectory( publicId, systemId )+ "\wml_1_1.xml")); } catch( java.io.FileNotFoundException e ) { return null; } } } then before parsing the XML stream set the entity resolver with: parser.setEntityResolver( new LocalDriveEntityResolver( ) ); Hope this helps... Javier