4 ms·
Interesting. I have validation of our internal (overly) complex configuration files on my todo list, and I'll have a look at using that, thanks!
by Deukhoofd 5y ago
Interesting. I have validation of our internal (overly) complex configuration files on my todo list, and I'll have a look at using that, thanks!
- DonHopkins 5y agoJames Clark argues that it's useful to have multiple specialized schema definition languages, each for their own purpose, so putting one reference to one "official" schema in one "official" language inside the document doesn't make sense. For example, you might want to perform one kind of quick simple input sanity checking validation that ensures the input won't crash your processor, to perform in real time on millions of XML documents you receive every minute. Then you might also want another more elaborate schema with an anal retentive formal specification, including text syntax checking, data type validation, cross-reference checking, constraints between values, and documentation, for creating and editing the same document in a schema-driven editor. https://github.com/michmech/xonomy https://github.com/michmech/xonomy It's also a bad idea to interpret the URI of a schema as the URL from which you can download the schema definition. That introduce security and privacy and interoperability problems. Internet Explorer used to try to download the schema definition every time you opened an XML document, which lets whoever controls that web site know you're looking at one of their documents, and what its url is in the referer field. It's like XML's answer to the 1x1 transparent GIF tracking cookie! Unlike DTDs and XML Schema, RELAX NG doesn't presume that it's the only schema language in the world that you will ever need to use: there are other useful languages like Schematron, which do things that RELEX NG was designed not to do on purpose. https://www.schematron.com/ https://www.schematron.com/ (There's a great Ven diagram comparing XSD, DTD, RELAX NG and Schematron's scope on that page.) https://www.schematron.com/document/2755.html https://www.schematron.com/document/2755.html >Schematron can be useful in conjunction with many grammar-based structure-validation languages: DTDs, XML Schemas, RELAX, TREX, etc. Indeed, Schematron is part of an ISO standard (DSDL: Document Schema Description Languages) designed to allow multiple, well-focussed XML validation languages to work together. You can even embed a Schematron schema inside an XML Schema <appinfo> element or inside a RELAX NG schema! James Clark on RELAX NG and xml:id: https://blog.jclark.com/2009/01/relax-ng-and-xmlid.html https://blog.jclark.com/2009/01/relax-ng-and-xmlid.html >RELAX NG and xml:id >One part of the vision underlying RELAX NG is that validation should not be monolithic: it is not necessary or desirable to have one schema language that can handle every possible kind of validation you might want to do; it is better instead to have multiple specialized languages, each of which does one kind validation, really well. Consistent with this vision, RELAX NG provides only grammar-based validation. There's no implicit claim that other kinds of validation aren't useful and important. >One kind of validation that is clearly useful and important and that can't be done by grammars is checking of cross-references. One possibility is to use Schematron for this. The designers of RELAX NG anticipated that there would be a little schema language specialized to this, which would be created as part of the ISO DSDL effort (as part 6); this wouldn't be a million miles from the kind of thing that XSD provides with xs:key/xs:unique/xs:keyref. Unfortunately this hasn't happened yet. [...]
- DonHopkins 5y agoAnother nice thing about RELAX NG is that not only does it have an XML format, but it also has a nice clean, much simpler to read and write, "compact syntax", which is equivalent to the XML format, and can be translated back and forth without losing any information. It's not all goofy and arbitrary and complex line noise like XML DTDs, and it's not all verbose and clumsy namespaced XML tags and attributes like XML Scheme documents. It even supports inheritance, and grammar as well as element level annotations (useful for schema and meta processing tools and editors). RELAX NG's Compact Syntax: https://www.xml.com/pub/a/2002/06/19/rng-compact.html https://www.xml.com/pub/a/2002/06/19/rng-compact.html RELAX NG Compact Syntax: Committee Specification 21 November 2002: https://www.oasis-open.org/committees/relax-ng/compact-20021121.html https://www.oasis-open.org/committees/relax-ng/compact-20021... RELAX NG Compact Syntax Tutorial: https://relaxng.org/compact-tutorial-20030326.html https://relaxng.org/compact-tutorial-20030326.html