Extend validation to catch styles from calling undefined macros

It’s been a known issue for some time that the current CSL schema has a
limitation when it comes to validation: styles that call undefined macros
still validate. At least one sloppy CSL author has made this mistake (
http://forums.zotero.org/discussion/7736/problems-citing-in-word-2007/), so
it’s clearly desirable to test for this. But as discussed in the forum
thread, RelaxNG doesn’t offer support for this type of validation. Bruce
pointed me to Schematron, and I’ve spent some time trying to built a
(non-embedded) Schematron schema. Fortunately, I found an example that
almost describes our case:
http://www.zvon.org/xxl/SchematronTutorial/Examples/Example17/example.html(which
seems to be written in Schematron 1.5). I should give a warning that
this example doesn’t work under xmllint (Schematron support in xmllint seems
to be quite limited). Jing, on the other hand, could cope with it. I’ve
extended the example to work with CSL styles, and I think everything works
properly now. I hope this can be easily incorporated into the commit
work-flow of the Style Repository. Maybe the Schematron code can be embedded
in the CSL schema. It’s something I haven’t checked. Please let me know if
you have any suggestions/questions.

The files:

Rintze

Rintze,

Your schema checks all text nodes; not just the ones with macro calls.

I add a macro-check.sch schema to trunk. Feel free to modify.

Bruce

Is that a problem? The “not(@macro)”-part should skip any text nodes that
don’t call macros.

Rintze

I just don’t think it’s as clear, and may be a little slower (though
trivially so). But YMMV.

Bruce

Corrected: http://sourceforge.net/apps/trac/xbiblio/changeset/1059

(didn’t know contexts could also specify required arguments)

Rintze