The XSD2SCH software is available from GitHub. It uses the MIT Open Source license.
This implementation takes the approach of converting the XML Schema to Schematron code. The methods used have been explored and documented here.
The software is not actively maintained, but is interesting as a source of ideas: if you are interested in maintaining and improving it, fork it, or contact the GitHub Schematron honcho.
Coverage
CAVEAT: The code was developed for a specific subset of XSD 1.0. It has not been tested on documents outside the specific kinds of ones for this subset. Do not have high expectations if you use any sophisticated features of XSD!
The coverage is approximately:
- simple datatypes: believed to be 100%
- list and union datatypes: not supported
- structural constraints on elements and attributes: supported¹
- multiple namespaces, import and include: supported²
- identity constraints: not supported
- dynamic constraints: (xsi:type, xsi:nill) not supported
- tricky prefixes: (elementFormDefault) not supported
- 1. Content model validation is implemented by a series of finer sieves, which combine
to provide most of the capabilities of a full grammar checker. If a grammar has repeated
particles or complex nested occurrence constraints, there may be some false positives where our sieves are not fine enough, however there are never false negatives. - 2. Include may have limitations.
Architecture
The converter is a pipeline:
The ZIP archive has a sample ANT file. Please note that this requires XSLT2 and an ability to create the necessary scripts, make or batch files to run. (The ANT file uses a version of the Schematron task for ANT, also on GitHub. Substitute your own Schematron implementation if necessary.)