Hi, I just wanted to point out that one problem with using an EntityResolver (as described below) to check/hack the DTD specified by an incoming XML file is that if the xml file does not specify any DTD, then the EntityResolver is not invoked...
This seems like a pretty common requirement :- to check that an incoming file complies with a specific schema or DTD. Yes, the latest Xerces releases do have a "revalidator" API, but I gather this is not stable yet?? So does anyone know if there a decent way to do this at the moment? Cheers, Simon Oh, and pease read "Laurent" (the original email author) in place of Micael (replier) below. I got the names mixed up.. On Mon, 2002-12-02 at 11:26, Simon Kitching wrote: > Hi, > > I believe that Micael is asking how to validate an input file against a > *specific* local DTD file, regardless of what DTD is specified in the > DOCTYPE of the input file. > > I too would be interested in hearing about any good solutions to this. > > Micael, one solution to this is to write a custom EntityResolver, which > either: > (a) checks that the DTD name (public or system) passed to it is the > expected DTD name, or > (b) always returns the contents of the DTD you want to validate against, > regardless of what DTD is specified in the document. > > See the javadoc for class org.xml.sax.EntityResolver for more info. > > Regards, > > Simon > > On Mon, 2002-12-02 at 11:05, micael wrote: > > Are you just trying to find out how to connect a dtd to a given xml > > file? If so, that is part of the xml file itself. > > > > At 10:56 PM 12/1/2002 +0100, you wrote: > > >Hi, > > > > > >I explain u my problem. > > > > > >I developp a program that reads it configuration into > > >a xml file. > > >The xml file references a dtd ( project.dtd ). > > > > > >The problem is if i use any other well formatted xml > > >referencing another dtd. > > > > > >The parsing works and it is normal but this xml > > >file is not valid for my program. > > > > > >I would like to verify for a xml file that the used > > >dtd is well "project.dtd" and not another one. > > > > > >How can i do that ? > > > > > >i use Xerces-J-2.2.1 and i parse using the SAX Method. > > > > > >Thanks > > > > > > > Micael -- Simon Kitching <[EMAIL PROTECTED]> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
