XAML validation rules for XML editors

Note: this entry has moved.

Rob asks for feeback on rule description so that any editor can offer validation and intellisense of XAML documents. We certainly know WXS isn't enough, as it has been discussed for the attached properties syntax. Rob says they provide:
  1. a schema - xaml.xsd (the Longhorn SDK installs it)
  2. a set of rules/constraints that we can't easily describe in schema (not adequately documented yet)
  3. a set of assemblies - using reflection tools could understand what elements exist, their properties, events, etc...

The important one is the second, because the third would be useless to any tool that doesn't use .NET code. Expressing rules that can't be described in a WXS is a long standing issue. We all know XPath. Arbitrary complex rules can be expressed with, such as co-occurence constraints, content models dependent on attribute values, etc. Instead of "documenting" those additional rules, why aren't they written as XPath assertions?
Furthermore, it has been demonstrated (and free XSLT-based, .NET and Java implementations are available) that an XPath-based standard language can be embedded both in RelaxNG and WXS, offering the best of both worlds. Discussion around the language and its features can be found at XML.com, and there are many comparisons that show its advantages and flexibility for rules expression. In a meeting with the most important names in the XML schemas world, analysis by the experts in each language showed these results ( adding up the 'yes' to the features analyzed-see scorecards, with 1/2 point for 'some' support):

  1. Schematron: 27
  2. RELAX NG: 20.5
  3. WXS: 16
  4. DTD: 8.5

What's more, it's undergoing ISO standarization, so you can be sure it won't become propietary or dissapear. Therefore, integrating it (either through XSLT or other languages implementation such as James Clark's Jing, SUN's MultiSchema validator, Schematron.NET, etc.) into an editor wouldn't be that much hard. Even Cocoon uses it for validation.

So, the bottom line is: implement WXS + RelaxNG schemas for the document structure. Embed or provide a separate Schematron schema for the additional rules. I'm sure most companies will be much more satisfied than by a document stating these rules in plain english....

Update: SUN provides a free tool to convert from several schema languages (including WXS) to RelaxNG, so MS don't bother to provide it.

No Comments