I just read Choose RELAX Now (Tim Bray) and RELAX NG Wins (Elliotte Rusty Harold) and spent today learning more about RELAX NG.

Some Background

To give some perspective on the length of my involvement with XML and defining schemas: I was working with XML in one of its earliest uses at Microsoft. In 1997 we were using XML (as it existed) & the WebDAV protocol to provide access to content in the Exchange Server store. Now you know why my name appears in the acknowledgements section of RFC2581.

My typical encounter with XSD involves its presence functional specifications at Microsoft. Without going into a full accounting of every event: the common end result is that it was hard to read, hard to understand, hard to learn, and hard to communicate with. I maintain that specs should be understandable. (For what meaning is a reader's feedback if he didnt understand what the author intended to express?) In my experience, XSD simply didn't contribute to understandability.

 

Let's Compare

Here's an XSD example taken from Wikipedia:

<xs:schema
 xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:element name="country" type="Country"/>
 <xs:complexType name="Country">
  <xs:sequence>
   <xs:element name="name" type="xs:string"/>
   <xs:element name="population" type="xs:decimal"/>
  </xs:sequence>
 </xs:complexType>
</xs:schema>

Here's a RELAX NG schema (using its compact syntax) for something similar:

element Country
{
element name { text },
element population { xsd:int }
}

 

I am going adopt RELAX NG

This means three things:

  • If I need to define an XML schema, I'm going to use RELAX NG
  • If someone asks me to sign-off on their schema, I will ask them to provide it in RELAX NG form.
  • In general, I will promote the use of RELAX NG.

Final thoughts

  • Please don't take my adoption of RELAX NG to mean that I consider it a "silver bullet" for XML that solves every problem people have. I'm saying only that it will be an incredibly helpful tool to communicate with others.
  • It doesn't have to be the best schema language in the world. It just has to be good, simple, and "just work". 
  • Tools/API support - Yes, support lags. That will change. In the meantime I can at least drive its use in the way we communicate about schema.
  • Does XSD go away? It's still useful and will be for some time. 

Additional Resources