Re: [xml] DTDs
- From: Daniel Veillard <veillard redhat com>
- To: Daniel Gehriger <gehriger linkcad com>
- Cc: xml gnome org
- Subject: Re: [xml] DTDs
- Date: Mon, 26 Aug 2002 17:32:22 -0400
On Mon, Aug 26, 2002 at 08:14:57PM +0200, Daniel Gehriger wrote:
Hi,
I have a general question about DTDs (which also applies to Schemas) :
as a program developer, validating an XML file against a DTD gives me
the assurance that the XML file follows a certain layout, and that I
don't have to check for any special cases or missing elements. Instead,
I can just go ahead and use the data in the XML file.
So my question : why then is the DTD or the reference to the external
DTD specified inside the XML file ? I certainly don't want let the
author of the XML file change the DTD. In my understanding, the DTD,
which the XML file is validated against, should be hardcoded / compiled
into the program that reads the XML file.
Because "validation" is just one of the aspects of the usefullness fo DTD
entities definitions and attributes defaulting are two aspects for which
trusting the author is no problem.
This is how I handle it now: I require an external DTD declaration in
the XML file. I also register an external entity loader with libxml2,
which checks for the specifiy id/url, and provides the DTD from memory.
Once loaded, I check the parse tree to make sure that indeed this
external DTD declaration has been specified, and with the correct URL /
id. Finally I have libxml2 validate the XML file.
Any comments on this procedure ?
Fine, very close to catalogs. Another possibility is to not
switch DTD parsing and have a (set of) preparsed DTD(s) and use
xmlValidateDtd() to check the documents against the DTD(s)
after parsing.
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]