RELAX NG vs. XML Schema
Over on the MODS list, I’ve been involved in an interesting discussion about design choices in schema development. While I had a strong impression that there were problems with XML Schema quite apart from its complexity, this discussion showed me things are worse in the XSD world than I imagined.
Basic things I take for granted in RELAX NG are simply not possible in XSD. Consider, for example, something so basic as this in RELAX NG:
Name = element name {(Name-Given | Name-Family)+}
Name-Given = element namePart {attribute type {"given"}, text}
Name-Family = element namePart {attribute type {"family"}, text }
Nope; you can’t do it in XSD. It seems XSD does not allow one to define the same top-level element in different places (never mind that they have different attributes, or that in other cases they will be used in different contexts).
Now, what about this: you want to create a library of definitions and simply include them into various other schemas at will. However, those schemas each have different namespaces. RELAX NG does as you would expect: it allows you to leave a default namespaces off of the library. When those definitions are used in schemas, they take on the default namespace of that schema.
Once again: you cannot do this in XSD.
How about conditioning validation of a document based on an attribute value? Again, you cannot do it in XSD.
It’s really quite frustrating to watch how bad design choices of an industry standard limit the way XML designers can approach the problems of schema development. It’s also frustrating to continue to see large organizations like the Library of Congress and Apple invest tons of energy and money into a clearly broken standard, when there’s a better alternative in RELAX NG. I—an amateur developer with just over a year of experience with RELAX NG—can write better, more compliant, XSD schemas by authoring them by hand in the RELAX NG Compact Syntax and converting with Trang than it seems many professionals can working with XSD directly in an expensive commercial editor (XMLSpy). What does that say?
Creative Commons License