A validator for XUL could be a good idea. I am thinking about something more than just ‘schema’ validation. Something to help with best practices and accessibility. Maybe ‘validator’ isn’t the right word. Here are some checks that could be useful:
- Basic Structure – Stuff a schema language would check:
- Is the XML well formed?
- Are any elements unknown?
- For a given element, are any attributes unknown?
- For a given element, is it the child of a valid parent?
- For a given attribute, are the values allowed?
- Best Practices – Stuff that’s recommended for a good, localizable, skinnable and accessible UI:
- Are access keys on menus, checkboxes, radiobuttons, buttons and labels linked to controls?
- Are labels linked to controls using
control
attribute? - Do toolbarbuttons have labels and tooltips (even if the label is hidden)?
- Are there menu alternatives to toolbar actions (use
keyset
andcommandset
)? - Is the
context
attribute used to attach context menus? - Are radiogroups contained in a groupbox with a caption?
- Does the source declare a DTD for localization of string resources?
- Are labels, captions, accesskeys and other strings pulled from a DTD?
- Does the source import a stylesheet (exception: overlays)?
- Are toolbar, menu and button images assigned via CSS or hard coded
image
attributes? - Does the source avoid using inline
style
?
What else could a validator check? I pulled some of these from a good MDC article on accessibility guidelines. Localization is definitely important and MDC has guidelines and examples to help. The skinning stuff came from this skin/CSS guide.
I have most of these checks in the current version of XUL Explorer (to be released soon). I was planning a simple web version too.
Note: There is a web-based accessibility checker for XUL (and other types) at WebAIM. To test it, choose “XUL Report” for the LRAE file and pick “Form Test (XUL)” or “Browser (XUL)”, then press “Process” button. You can also supply your own XUL URL.
Update: Added localization and skinning guidelines to the list (thanks Axel)