This distribution contains the XML Schema validation engine which is integrated in XMLmind XML Editor (XXE).
This engine has been made available to schema and DTD authors in the form of 3 command-line tools:
Features:
Non features:
Xsdvalid and dtdvalid have been tested with:
Procedure:
$ cd $ gzip -d -c xsdvalid-20p2.tgz | tar xvf - $ ls xsdvalid-1 docs/ xp.jar resolver.jar xsdvalid.jar xsdvalid xsdvalid.bat dtdvalid dtdvalid.bat dtdtoxsd dtdtoxsd.bat ...
$ su $ cp ~/xsdvalid-20p2/xsdvalid /usr/local/bin $ cp ~/xsdvalid-20p2/dtdvalid /usr/local/bin $ cp ~/xsdvalid-20p2/dtdtoxsd /usr/local/bin $ cp ~/xsdvalid-20p2/*.jar /usr/local/bin $ chmod a+rx /usr/local/bin/xsdvalid $ chmod a+rx /usr/local/bin/dtdvalid $ chmod a+rx /usr/local/bin/dtdtoxsd $ chmod a+r /usr/local/bin/*.jar
Install on Windows is similar to the install on Unix but under Windows you'll have to copy xsdvalid.bat, dtdvalid.bat and dtdtoxsd.bat rather than the xsdvalid, dtdvalid and dtdtoxsd shell scripts.
These excellent packages have not been developed by XMLmind. Copyright information is contained in the corresponding .LICENSE file. Read the corresponding .README file to have more details about these packages.
xsdvalid ?options? ?xml_doc ... xml_doc?
Checks an XML schema for validity. Checks an XML document for validity against an XML schema.
Options:
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.
Limitations:
Examples:
$ xsdvalid -s bugreport.xsd
$ xsdvalid sample.xml
$ 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]
$ xsdvalid -s bugreport.xsd -w serial $ ls serial/ directory.txt schema0.ser
$ xsdvalid -v -r serial -ss http://www.xmlmind.com/xmleditor/schemas 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)
dtdvalid ?options? ?xml_doc ... xml_doc?
Checks a DTD for validity. Checks an XML document for validity against a DTD.
Options:
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.
Notes:
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:
$ dtdvalid -d xhtml1-strict.dtd
$ dtdvalid sample.xhtml
$ 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]
$ dtdvalid -dd "-//W3C//DTD XHTML 1.0 Strict//EN" xhtml1-strict.dtd -w serial $ ls serial/ directory.txt schema0.ent schema0.ser
$ 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)
dtdtoxsd ?options? in_dtd_file out_xsd_file
Converts DTD in_dtd_file to XML-Schema out_xsd_file.
Options:
If the DTD declares text, external or unparsed entities, these declarations are copied to a file which has the same basename as out_xsd_file but with extension .ent. This file is created in the same directory as out_xsd_file.
In addition to out_xsd_file, a schema file named xml.xsd is created in the same directory as out_xsd_file. This secondary schema declares standard attributes xml:space, xml:lang and xml:base. The main schema always imports xml.xsd even if it doesn't reference any of the standard attributes.
Limitations:
Examples:
$ dtdtoxsd -t http://www.w3.org/1999/xhtml xhtml1-strict.dtd /tmp/xhtml.xsd $ ls /tmp xhtml.ent xhtml.xsd xml.xsd
Formal reference: XML Schema Part 2: Datatypes.
Formal reference: XML Schema Part 1: Structures.
Constraints on XML instances which are not checked:
Constraints on XML schemas which are not checked:
In this case, the implementation simply overwrites the previously defined group.
In this case, the implementation simply overwrites the previously defined attributeGroup.
attributeGroups are not validated as such. If something is wrong, it is detected when the the attributeGroup is actually used.
Example 1: circular references are checked when the attributeGroup is actually used.
Example 2: duplicate attribute and several ID attributes in the same attributeGroup are checked when the attributeGroup is actually used.
groups are not validated as such. If something is wrong, it is detected when the the group is actually used.
The implementation allows to add facets not defined by the base type.
Other specificities:
Rationale: the schema for schemas is found invalid when the algorithm described in the spec is used.
Formal reference: Extensible Markup Language (XML) 1.0 (Second Edition).
Constraints on XML instances which are not checked:
Constraints on DTDs which are not checked:
Changed version number to V2 to use the same version number as XXE.
Forgot to update the documentation for the release of Patch2.
Validating really large XML schemas on Windows was not possible due to a stack overflow error. Increasing the stack size by editing xsdvalid.bat and adding -Xss1m to the Java command line had no effect.
Xsdvalid 1.0 Patch2 requires Java 1.4. It will not run with Java 1.3. Do not upgrade if you cannot install Java 1.4 on your machine.
Fixed an obscure bug related to restrictions of the NMTOKENS, IDREFS, and ENTITIES simple types.
Initial release.