Re: [xml] xmllint DTD question

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

 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:
<> "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 <>, 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
<>, 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.


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