xsdvalid ?options? ?xml_doc ... xml_doc?
Checks a W3C XML schema for validity. Checks one or more XML documents for validity against a W3C XML schema.
Options:
Generate report in file file. Default: output report to console.
Use schema schema to validate XML documents. Default: use what is specified by xsi:schemaLocation and xsi:noNamespaceSchemaLocation.
Same as -s except that first parameter specifies the target namespace of the schema. This target namespace is mandatory if the schema is to be deserialized.
Load serialized schemas from directory dir if found there, otherwise load schemas from their XML sources.
Serialize loaded schemas to directory dir.
Generate documentation in directory dir.
See note about the generated documentation.
Add link to specified CSS URL in generated documentation.
Be verbose. Default: be quiet.
It is possible to specify several -s and -ss options. Such multiple schemas (and their included/imported schemas, if any) are merged into one big global schema.
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 (';
').
XML catalogs may be used to resolve URLs found in the following places:
Schema locations in xsi:schemaLocation
and in xsi:noNamespaceSchemaLocation
.
Schema locations in xs:include
, xs:redefine
, xs:import
.
DTD locations in <!DOCTYPE>
(typically used to define character entities).
Limitations:
xsdvalid will not found xsi:schemaLocation
and xsi:noNamespaceSchemaLocation
attributes if specified on a element other that the root element of the XML instance.
Examples:
Validate schema bugreport.xsd
(which happens to import xhtml.xsd
).
$ xsdvalid -s bugreport.xsd
Validate XML document sample.xml
against the schemas specified in the xsi:schemaLocation
and xsi:noNamespaceSchemaLocation
attributes.
$ xsdvalid sample.xml
Validate XML document bad.xml against the schema bugreport.xsd
, possibly overriding the schemas specified in the xsi:schemaLocation
and xsi:noNamespaceSchemaLocation
attributes.
$ xsdvalid -s bugreport.xsd bad.xml file:/home/hussein/src/xxe/distrib/samples/xsdvalid/bad.xml:E:9:2: element contains invalid data: "M1.2p" does not match pattern "^((M|V)\d+\.\d+(p\d+)?)$" [cvc-pattern-valid] [cvc-type.3.1.3] file:/home/hussein/src/xxe/distrib/samples/xsdvalid/bad.xml:E:11:2: element contains invalid data: syntax error in dateTime value "2001-13-16T12:00:00" [cvc-datatype-valid.1.2.1] [cvc-type.3.1.3] file:/home/hussein/src/xxe/distrib/samples/xsdvalid/bad.xml:E:12:15: the sequence of child elements is incorrect [cvc-complex-type.2.4] file:/home/hussein/src/xxe/distrib/samples/xsdvalid/bad.xml:E:12:15: element cannot contain element "html:font" [cvc-complex-type] file:/home/hussein/src/xxe/distrib/samples/xsdvalid/bad.xml:E:24:0: the sequence of child elements is incorrect [cvc-complex-type.2.4] file:/home/hussein/src/xxe/distrib/samples/xsdvalid/bad.xml:E:36:0: element has no attribute "number" [cvc-complex-type.3] file:/home/hussein/src/xxe/distrib/samples/xsdvalid/bad.xml:E:37:2: element contains invalid data: "xsd" is not one of the allowed values [cvc-enumeration-valid] [cvc-type.3.1.3]
Serialize bugreport.xsd
(merged with imported schema xhtml.xsd
) to directory serial/
.
$ xsdvalid -s bugreport.xsd -w serial $ ls serial/ directory.txt schema0.ser
Validate sample.xml
against bugreport.xsd
, deserialized from directory serial/
.
$ xsdvalid -v -r serial \ -ss http://www.xmlmind.com/xmleditor/schema/bugreport \ bugreport.xsd sample.xml Deserializing schema 'http://www.xmlmind.com/xmleditor/schemas' (1582ms) Loading XML document 'sample.xml' (457ms) Validating 'sample.xml' (182ms)
Note that sample.xml has an xsi:schemaLocation
attribute, therefore there is no need to use option -ss even when the schema is to be deserialized.
$ xsdvalid -v -r serial sample.xml Loading XML document 'sample.xml' (491ms) Deserializing schema 'http://www.xmlmind.com/xmleditor/schemas' (1533ms) Validating 'sample.xml' (189ms)
The generated HTML reference manual, organized like "DocBook: The Definitive Guide" by Norman Walsh and al., lists all elements and attributes specified in the W3C XML schema or DTD.
This manual is intended to help content authors create instances conforming to a given XML schema or DTD. This manual is not intended to help XML schema or DTD authors document their design.
Note that, for now, the documentation generator cannot extract documentation contained in a schema (i.e. in annotation
/documentation
elements) and merge extracted documentation with automatically generated documentation.