4 ms·
There's a bit more to it, though. XSD keeps backward-compat with XML DTDs, and XML DTDs, in turn, keep compatibility with full SGML DTDs (XML being specified as
by tannhaeuser 6y ago
There's a bit more to it, though. XSD keeps backward-compat with XML DTDs, and XML DTDs, in turn, keep compatibility with full SGML DTDs (XML being specified as an SGML subset). Now DTDs are usually required in SGML unless you're using XML-style canonical markup without omitted tags and attribute names. What makes them required in regular SGML is that element declarations carry tag omission indicators instructing an SGML parser to infer contextually required tags. Tag inference in SGML is deterministic; that is, the parser only considers start-element tags that are required and end-element tags for definitely completed content models at the context position. Also, in the presence of tag omission, an SGML DTD is required even for parsing (for example, HTML cannot be parsed using generic XML rules but needs element-specific content and tag omission rules).
So the design rationale for XSDs to retain backward-compat (what's responsible for XSD's "unique particle attribution" constraint) leads to a different result compared to RNG. By contrast, RNG is a "clean restart" working only for canonical XML-style markup, and is always optional (and only used for "validation").
One could argue XML took away what makes SGML a true authoring format to result in only a canonical delivery format, but these were willful design choices when XML was subset from SGML.
Now as to whether XSD's or RNG's format for grammars are prettier is a moot point. IMO there was never a reason for using an alternate XML syntax for SGML/XML DTD regular expressions/regular content models. Eg compare your example with it's equivalent (simple, compact) traditional element declaration:
<!element book - - page+>