InfoQ

News

Should you be using RELAX-NG?

Posted by Gavin Terrill on Oct 29, 2007

Community
Architecture
Topics
Technology ,
Domain Specific Languages
Tags
RELAX-NG ,
W3C ,
XML Schema

RELAX-NG (pronounced "relaxing") is an alternative XML schema definition language characterized by being simpler and more elegant than the more generally known DTD or XSD based languages. W3C XML Schemas in particular has garnered a reputation as being overly complex, with XML luminaries such as Tim Bray commenting:

W3C XML Schemas (XSD) suck. They are hard to read, hard to write, hard to understand, have interoperability problems, and are unable to describe lots of things you want to do all the time in XML.

To help condense some of the information scattered around the internet on the virtues on RELAX-NG, Griffin Brown recently listed 10 reasons to model XML with RELAX NG , not W3C XML Schema. The list includes:

  1. "A better spec means better interoperability".
  2. "Availability of a compact syntax" (RELAX-NG supports a DSL that concisely expresses constraints without resorting to pointy brackets).
  3. "The specification is a stable ISO standard".
  4. "No PSVI" (PSVI is considered harmful).
  5. "No content defaulting".
  6. "Better data typing support".
  7. "More sophisticated modeling".
  8. "More sophisticated grammatical validation".
  9. "Instances have no dependency".
  10. "Growing consensus".
Converting XSD files to RELAX-NG (.RNG) can be accomplished using the "Sun Multi-Schema Validator" tool, which produces verbose format .RNG files. Trang can then be used to convert to these to the compact form.
Must be 10x easier than the incumbant by Noah Campbell Posted Oct 30, 2007 10:59 AM
Re: Must be 10x easier than the incumbant by Jean-Jacques Dubray Posted Oct 30, 2007 12:48 PM
Re: Must be 10x easier than the incumbant by Jose Alberto Fernandez Posted Nov 6, 2007 12:17 PM
Re: Must be 10x easier than the incumbant by Joshua Graham Posted Nov 6, 2007 2:56 PM
And embed Schematron for XPath-based rules by Joshua Graham Posted Nov 6, 2007 3:24 PM
  1. Back to top

    Must be 10x easier than the incumbant

    Oct 30, 2007 10:59 AM by Noah Campbell

    ...before you'll see folks switch.

    Brown points out 10 things that are arguably qualitative, not quantitative. XML-Schema, if anything, is complex, but not necessarily deficient.

    I'm all for adopting standards that are easier to approach since xml schema modeling is very important. Again, it's hard to justify a switch in schema tooling when a good deal of infrastructure won't support it.

  2. Back to top

    Re: Must be 10x easier than the incumbant

    Oct 30, 2007 12:48 PM by Jean-Jacques Dubray

    I agree with Noah. I am not a specialist of relax-ng by any means but a quick look at the spec seem to indicate that the extensibility of the language are weak (foreign elements and attributes seem to be limited to ##other namespace). If this is the case, this is a severe limitation and setback incompatible with SOA.

    I did not see any performance comparison, it would be interesting how validation compares in both cases.

    I agree that XML Schema is complex (tools somehow mitigate it) but I need this complexity. The question is for the casual designer of schemas (say a few schemas a year), what is the best approach for him or her? is a tool enough? Do we really need a new syntax?

    I like the vision of David Chappell that seem to indicate that XML, WSDL, XSD, BPEL... are the byte code level of the technology. I am not sure we need more byte code level technologies.

    Not convinced so far...

  3. Back to top

    Re: Must be 10x easier than the incumbant

    Nov 6, 2007 12:17 PM by Jose Alberto Fernandez

    We use RelaxNG compact extensively in our systems. It is so easy to write that there is no need for complex tools. The Java XML parsers support it perfectly.

    You can import definitions, use multiple name-spaces, use overriding of definitions and much more with ease. And almost any human with minimal knowledge of context-free grammars can understand them easily. It has the correct level of syntax sugar necessary to allow you to express complex schemas succinctly.

    I do not wish XSD on anyone, not even on my worst enemy.

  4. Back to top

    Re: Must be 10x easier than the incumbant

    Nov 6, 2007 2:56 PM by Joshua Graham

    +1. "If WSDL is a turd, then XSD is the dodgy curry that makes it stink" - me.

  5. Back to top

    And embed Schematron for XPath-based rules

    Nov 6, 2007 3:24 PM by Joshua Graham

    ...very nice.

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.