4. Dtdvalid command reference
Prev |  | Next

## 4. Dtdvalid command reference

dtdvalid ?options? ?xml_doc ... xml_doc?

Checks a DTD for validity. Checks one or more XML documents for validity against a DTD.

Options:

-o file

  Generate report in file file. Default: output report to console.

-d dtd

  Use DTD dtd to validate XML documents. Default: use DTD specified in the XML document.

-dd pubid dtd

  Same as -d except that first parameter specifies the public ID of the DTD. This public ID is mandatory if the DTD is to be serialized or deserialized.

-r dir

  Load serialized DTDs from directory dir if found there, otherwise load DTDs from their XML sources.

-w dir

  Serialize loaded DTDs to directory dir.

-gendoc dir

  Generate documentation in directory dir.

  See note about the generated documentation.

-css URL

  Add link to specified CSS URL in generated documentation.

-v

  Be verbose. Default: be quiet.

When the -d or -dd command-line options are used, the constraint that the root element of an XML instance and the document element of the DTD must match is not checked.

This command is XML catalog aware. This command will use the XML catalogs specified in environment variable `XML_CATALOG_FILES`. This variable must contain one or several XML catalog file names or URLs separated by a semi-colon ('`;`').

Notes:

- An XML instance which references entities (such as &nbsp;) must have a <!DOCTYPE> containing the declarations of these entities, even when the DTD to be used is specified with the -d or -dd options.

- A DTD document (that is, a file with the .dtd extension) is serialized with a dummy document element name called "dummy".

  Therefore, if an XML document to be validated references such serialized DTD in its <!DOCTYPE>, dtdvalid will always complain that the root element in the XML instance does not match document element named "dummy".

  The method to get rid of this false alert is to always specify such serialized DTD using the -dd command-line option.

Examples:

- Validate DTD `xhtml1-strict.dtd`.

      $ dtdvalid -d xhtml1-strict.dtd

- Validate XML document `sample.xhtml` using the DTD specified in <!DOCTYPE>.

      $ dtdvalid sample.xhtml

- Validate XML document `bad.xhtml` against `xhtml1-strict.dtd`, possibly overriding the DTD specified in <!DOCTYPE>.

      $ dtdvalid -d xhtml1-strict.dtd bad.xhtml
      file:/home/hussein/src/xxe/distrib/samples/dtdvalid/bad.xhtml:E:7:2:
      element contains characters other than white space [cvc-complex-type.2.3]
      file:/home/hussein/src/xxe/distrib/samples/dtdvalid/bad.xhtml:E:8:4:
      element has no attribute "align" [cvc-complex-type.3]
      file:/home/hussein/src/xxe/distrib/samples/dtdvalid/bad.xhtml:E:13:4:
      the sequence of child elements is incorrect [cvc-complex-type.2.4]
      file:/home/hussein/src/xxe/distrib/samples/dtdvalid/bad.xhtml:E:13:4:
      element cannot contain element "hr" [cvc-complex-type]

- Serialize DTD `xhtml1-strict.dtd` to directory `serial/`.

      $ dtdvalid -dd "-//W3C//DTD XHTML 1.0 Strict//EN" xhtml1-strict.dtd -w serial
      $ ls serial/
      directory.txt
      schema0.ent
      schema0.ser

- Validate XML document `sample.xhtml` using `xhtml1-strict.dtd`, deserialized from directory `serial/`.

      $ dtdvalid -v -r serial \
          -dd "-//W3C//DTD XHTML 1.0 Strict//EN" xhtml1-strict.dtd sample.xhtml
      Deserializing global DTD '-//W3C//DTD XHTML 1.0 Strict//EN' (1079ms)
      Loading XML document 'sample.xhtml' (748ms)
      Validating 'sample.xhtml' (180ms)

Prev |  | Next
3. Xsdvalid command reference | Home | 5. Rngvalid command reference