Re: [xml] xmllint DTD question



On 29/04/2008, Alistair Leslie-Hughes <leslie_alistair hotmail com> wrote:
Hi,

 Load this attached file with libxml gives the following our
 I/O warning : failed to load external entity

 using xmllint
 xmllint --valid --noout room1.xml
 room1.xml:2: validity error : Validation failed: no DTD found !
 <wpkg >
       ^

 The file doesn't specify a DTD so why is it trying to look for one?

 Best Regards
  Alistair Leslie-Hughes

Short version: You don't want the --valid switch.

Long version:
<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.

Martin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]