You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Michenaud Laurent <lm...@free.fr> on 2002/12/01 22:56:34 UTC

Verifying DTD

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



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Verifying DTD

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
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 <si...@ecnetwork.co.nz>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Verifying DTD

Posted by Michenaud Laurent <lm...@free.fr>.
Hi,

Could u give me the code that gets the name of the DTD specified in a XML
File ?

> 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
>> >
>> >
>> >
>> >---------------------------------------------------------------------
>> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org For
>> additional commands, e-mail: xerces-j-user-help@xml.apache.org
>>
>> Micael
>>
>> -------------------------------------------------------
>>
>> This electronic mail  transmission and any accompanying documents
>> contain  information belonging to the sender which may be confidential
>> and legally  privileged.  This information is intended only for the
>> use of the  individual or entity to whom this electronic mail
>> transmission was sent as  indicated above. If you are not the intended
>> recipient, any disclosure,  copying, distribution, or action taken in
>> reliance on the contents of the  information contained in this
>> transmission is strictly prohibited.  If you  have received this
>> transmission in error, please delete the message.  Thank you
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org For
>> additional commands, e-mail: xerces-j-user-help@xml.apache.org
> --
> Simon Kitching <si...@ecnetwork.co.nz>
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Verifying DTD

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
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
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 
> Micael
> 
> -------------------------------------------------------
> 
> This electronic mail  transmission and any accompanying documents contain 
> information belonging to the sender which may be confidential and legally 
> privileged.  This information is intended only for the use of the 
> individual or entity to whom this electronic mail transmission was sent as 
> indicated above. If you are not the intended recipient, any disclosure, 
> copying, distribution, or action taken in reliance on the contents of the 
> information contained in this transmission is strictly prohibited.  If you 
> have received this transmission in error, please delete the message.  Thank you 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
-- 
Simon Kitching <si...@ecnetwork.co.nz>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Verifying DTD

Posted by micael <ca...@harbornet.com>.
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
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org

Micael

-------------------------------------------------------

This electronic mail  transmission and any accompanying documents contain 
information belonging to the sender which may be confidential and legally 
privileged.  This information is intended only for the use of the 
individual or entity to whom this electronic mail transmission was sent as 
indicated above. If you are not the intended recipient, any disclosure, 
copying, distribution, or action taken in reliance on the contents of the 
information contained in this transmission is strictly prohibited.  If you 
have received this transmission in error, please delete the message.  Thank you 



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org