Welcome to MSDN Blogs Sign in | Join | Help

RELAX NG Won?

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

Published Tuesday, November 28, 2006 9:31 PM by saveenr

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: RELAX NG Won?

You've compared the expanded XML-based syntax for xsd (granted the only current syntax for xsd) against the compact non-XML-based syntax for RelaxNG and claimed RelaxNG as the more simple of the two. Compare xsd to the xml-based RelaxNG syntax and see if it's as obvious. There's no reason someone couldn't come up with a compact non-XML-based syntax for xsd that would serve the same purpose for xsd that RelaxNG's does for it. Here's a shot:

schema CountrySchema

{

  complexType Country

  {

      string name;

      decimal population;

  }

  Country country;

}

Does RelaxNG have the concept of types? If so, your RelaxNG might not even correspond with the xsd example you've provided. I'd guess the equivalent type-based RelaxNG is slightly more complicated.

Wednesday, November 29, 2006 12:17 PM by SpoonsJTD

# re: RELAX NG Won?

True that I picked the compact format and I should have brought up that there is an XML format and (IMO) the XML format for RELAX NG is not as obvious as the compact format, but it still more readable than XSD. (In general, I find using either XML format difficult.)

If a compact form of XSD where available, then that would be great option. I just haven't seen any broad consensus on such a compact form.

There is some typing in RELAX NG (enough for my needs). Not clear to me that it covers all of what XSD provides.

Wednesday, November 29, 2006 1:28 PM by saveenr

# re: RELAX NG Won?

@SpoonsJTD: ... don't you mean he should have compared the XST compact syntax with the RNG compact syntax?

... what's that you say? XSD doesn't *have* a compact syntax? Hmm ... don't you think that should come up in any comparison of the two?

Wednesday, September 16, 2009 5:19 PM by Samuel Bronson

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker