Re: [xml] xmllint DTD question
- From: "Martin (gzlist)" <gzlist googlemail com>
- To: "Alistair Leslie-Hughes" <leslie_alistair hotmail com>
- Cc: xml gnome org
- Subject: Re: [xml] xmllint DTD question
- Date: Tue, 29 Apr 2008 13:08:19 +0100
On 29/04/2008, Alistair Leslie-Hughes <leslie_alistair hotmail com> wrote:
Load this attached file with libxml gives the following our
I/O warning : failed to load external entity
xmllint --valid --noout room1.xml
room1.xml:2: validity error : Validation failed: no DTD found !
The file doesn't specify a DTD so why is it trying to look for one?
Short version: You don't want the --valid switch.
<http://www.w3.org/TR/xml/#dt-valid> "An XML document is valid if it
has an associated document type declaration and if the document
complies with the constraints expressed in it."
If you just want to check if the document is well formed <
http://www.w3.org/TR/xml/#sec-well-formed>, all you need to do is run
it through a parser and see if it finishes with no errors.
All parsers, including non-validating ones
<http://www.w3.org/TR/xml/#proc-types>, must behave like this.
Note, there are newer schema languages that may be prefered to DTDs if
you want to look into enforcing validity constraints. There's some
support for all the most widely used ones in libxml2, see relaxng,
schematron, and xmlschemas c files.
] [Thread Prev