Design motivations of different schema languages

Posted on February 1, 2017 by Rick Jelliffe

The XML.COM website has Rick Jelliffe’s article  Schemas: Different Strokes for Different Folks

“Schema languages are the bedrock of XML software engineering; but why are they so different? Because their creators approached them with very different viewpoints about how software engineering should work.”

This prompted a discussion about closure on the XML-DEV mail list started by ODF editor Patrick Durusau.  This has resulted in the XML.COM article being clarified.

Closure is a mathematical property of a type and function: if a type is “closed” under the union function it means that the result of the union of something type A and something else type A is also type A.

RELAX NG provides a union operator, and you can take two RELAX NG schemas and apply them as arguments to the union opererator, and the resutl is a legitimate RELAX Schema.

Schematron, in contrast, does not supply a union operator, and so it cannot be “closed under union”.  (However, Schematron does provide an implicit top-level intersection functionality, so Schematron can characterized as “closed under intersection”, with a appropriate housekeeping for namespaces etc.)  The closest you can get in Schematron is to have one schema in one phase, and the other schema in another phase, and select which one you wish to test (or test each phase and pass the document if one succeeds.)