Comparing XML Schema Languages
by Eric van der Vlist
|
Pages: 1, 2, 3
Examplotron
Overview
| Author: | Eric van der Vlist |
| Status: | Unofficial |
| Location: | http://examplotron.org/ |
| PSVI: | No (not yet) |
| Structures: | Yes |
| Datatypes: | No (not directly) |
| Integrity: | No (not directly) |
| Rules: | Yes, through XPath expressions |
| Vendor support: | None |
| Miscellaneous: | Schema by example (a sample document is a schema) with rules checking (syntax borrowed to Schematron). |
Examplotron is an experiment to define a schema language based on sample trees, not unlike early proposals for XPath. An Examplotron schema for our sample could be:
<?xml version="1.0" encoding="UTF-8"?>
<library xmlns:eg="http://examplotron.org/0/">
<book id="_0836217462"
eg:occurs="+"
eg:assert="not(following-sibling::book/@id=@id) and @id=concat('_', isbn)">
<isbn>0836217462</isbn>
<title>Being a Dog Is a Full-Time Job</title>
<author-ref id="Charles-M.-Schulz" eg:occurs="*"/>
<character-ref id="Peppermint-Patty" eg:occurs="*"/>
</book>
<author id="Charles-M.-Schulz" eg:occurs="*">
<name>Charles M. Schulz</name>
<nickName>SPARKY</nickName>
<born>November 26, 1922</born>
<dead>February 12, 2000</dead>
</author>
<character id="Peppermint-Patty" eg:occurs="*">
<name>Peppermint Patty</name>
<since>Aug. 22, 1966</since>
<qualification>bold, brash and tomboyish</qualification>
</character>
</library>
Mix and Match
We have seen that the features of some of these languages are more complementary than overlapping, and there is room for interesting combinations, especially with Schematron and the structure and datatype-based languages.
Some early implementations are available which support the
embedding of Schematron rules in xs:annotation/xs:appinfo
W3C XML Schema elements. The combination of W3C XML Schema and
Schematron enables the use of each language for the purpose for which
it was designed: structure and datatype validation for W3C XML Schema,
and rules for Schematron. The power of the rules expressed with
Schematron can also compensate for he weaknesses of W3C XML
Schema.
Discussions are also underway to embed Schematron rules in RELAX NG schemas. This would then lead to a possible combination of RELAX NG for the structure, W3C XML Schema part 2 for the datatypes and Schematron for the rules, which would certainly demonstrate the extensibility of XML applications.
Comparisons
To wrap up, I will summarize the pros and cons of each language.
Tool support (as of today)
-
Best: DTD
-
Most promising: W3C XML Schema
-
Challenger: RELAX NG
-
Niche: Schematron and Examplotron
Features
-
Structures: DTD, W3C XML Schema, RELAX NG, Examplotron.
-
Datatype: W3C XML Schema
-
Integrity: W3C XML Schema, Schematron, Examplotron
-
Rules: Schematron, Examplotron
Flexibility (ability to describe a wide range of structures)
-
Most flexible: Schematron (but everything needs to be defined "by hand").
-
Most flexible structure-based language: RELAX NG.
-
Integrity: W3C XML Schema, Schematron, Examplotron
-
Challenger: Examplotron
-
Behind: W3C XML Schema
-
Least flexible: DTD (lack of namespace support)
So What?
There are currently no perfect XML Schema languages. Fortunately, there are a number of good choices, each with strengths and weaknesses, and these choices can be combined. Your job may be as simple as picking the right combination for your application.
References
-
(TAXO) Taxonomy of XML Schema Languages Using Formal Language Theory, By MURATA Makoto (International University of Japan, currently visiting IBM Tokyo Research Lab.) Dongwon Lee, and Murali Mani (University of California at Los Angeles/Computer Science Department). Presented at eXtreme Markup Language 2001, http://www.cobase.cs.ucla.edu/tech-docs/dongwon/mura0619.pdf
-
(CTX) The W3C XML Schema Specification in Context, article on XML.com by Rick Jelliffe 10-January-2001, http://www.xml.com/pub/a/2001/01/10/schemasincontext.html
-
(XMLS-CP) XML Schemas, The XML Cover Pages, http://www.oasis-open.org/cover/schemas.html
-
(XML) Extensible Markup Language (XML) 1.0 (Second Edition), W3C Recommendation, 6-October-2000, http://www.w3.org/TR/REC-xml
-
(XMLS0) XML Schema Part 0: Primer , W3C Recommendation, 2-May-2001, http://www.w3.org/TR/xmlschema-0/
-
(XMLS1) XML Schema Part 1: Structures, W3C Recommendation, 2-May-2001, http://www.w3.org/TR/xmlschema-1/
-
(XMLS2) XML Schema Part 2: Datatypes, W3C Recommendation, 2-May-2001, http://www.w3.org/TR/xmlschema-2/
-
(XMLCOM) Using W3C XML Schema, tutorial on XML.com by Eric van der Vlist, 17-October-2001
-
(RNG) RELAX NG, OASIS Technical Committee, http://www.oasis-open.org/committees/relax-ng/
-
(SCH) The Schematron, An XML Structure Validation Language using Patterns in Trees, http://www.ascc.net/xml/resource/schematron/schematron.html
-
(EG) Examplotron, Draft, 27-March-2001, http://examplotron.org/
-
(DDML) Document Definition Markup Language (DDML) Specification, Version 1.0 W3C Note, 19-Jan-1999, http://www.w3.org/TR/NOTE-ddml
-
(DCD) Document Content Description for XML , W3C Note, 31-July-1998, http://www.w3.org/TR/NOTE-dcd
-
(SOX) Schema for Object-Oriented XML 2.0, W3C Note, 30-July-1999, http://www.w3.org/TR/NOTE-SOX/
-
(XML-Data) XML-Data, W3C Note, 05-Jan-1998, http://www.w3.org/TR/1998/NOTE-XML-data/
-
(XDR) XML-Data reduced, Draft, 3-July-1998, http://www.ltg.ed.ac.uk/~ht/XMLData-Reduced.htm
-
(TREX) TREX, Tree Regular Expressions for XML, http://thaiopensource.com/trex/
-
(RLX) RELAX, Regular Language description for XML, http://www.xml.gr.jp/relax/