XML.com: XML From the Inside Out
oreilly.comSafari Bookshelf.Conferences.

advertisement

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)

  1. Best: DTD

  2. Most promising: W3C XML Schema

  3. Challenger: RELAX NG

  4. Niche: Schematron and Examplotron

Features

  1. Structures: DTD, W3C XML Schema, RELAX NG, Examplotron.

  2. Datatype: W3C XML Schema

  3. Integrity: W3C XML Schema, Schematron, Examplotron

  4. Rules: Schematron, Examplotron

Flexibility (ability to describe a wide range of structures)

  1. Most flexible: Schematron (but everything needs to be defined "by hand").

  2. Most flexible structure-based language: RELAX NG.

  3. Integrity: W3C XML Schema, Schematron, Examplotron

  4. Challenger: Examplotron

  5. Behind: W3C XML Schema

  6. 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



1 to 3 of 3
1 to 3 of 3