validate

Usage

validate [--yesno|:q] [document]validate [--yesno|:q] [--dtd|:D | --relaxng|:R | --schema|:S] --file|:f filename] [document]validate [--yesno|:q] [--dtd|:D | --relaxng|:R | --schema|:S] --string|:s expression] [document]validate [--yesno|:q] [--dtd|:D | --relaxng|:R | --schema|:S] --doc|:d document] [document]validate [--yesno|:q] [--dtd|:d] --public|:p expression [--file|:f expression] [document]

Description

This command validates the current document or a document specified in the argument against a DTD, RelaxNG or XSD schema. If --yesno or :q is specified, only prints yes and returns 1 if the document validates or no and returns 0 if it does not. Without --yesno, it throws an exception with a complete validation error message if the document doesn't validate.

--dtd or :D forces DTD validation (default).

--relaxng or :R forces RelaxNG validation. Only XML RelaxNG grammars are supported.

--schema or :S forces W3C XML Schema validation (XSD). Support for schema validation may still be incomplete (see libxml2 home page for more details).

A DTD subset can be specified by its PUBLIC identifier (with --public), by its SYSTEM identifier (with --file), or as a string (with --string). If none of these options is used, validation is performed against the internal or external DTD subset of the document being validated.

RelaxNG grammars and XML Schemas can either be specified either as a filename or url (with --file), as a string containing (with --string), or as a document currently open in XSH2 (with --doc).

$mydoc := open "test.xml"
# in all examples below, mydoc can be omitted
validate --yesno $mydoc; # validate against the document's DOCTYPE
validate --public "-//OASIS//DTD DocBook XML V4.1.2//EN" $mydoc
validate --file "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" $mydoc
validate --relaxng --file "test.rng" $mydoc
validate --relaxng --string $relaxschema $mydoc
$rng := open "test.rng"
validate --relaxng --doc $rng $mydoc
validate --schema --file "test.xsd" $mydoc
validate --schema --string $xsdschema $mydoc
$xsd := open "test.xsd"
validate --schema --doc $xsd $mydoc

See Also

dtd