One issue we need to tackle before 1.0 is validation. We need to make
it easy to precisely check that a CSL file is valid according to our
expectations. If someone chooses an author-date class, then they better
be using author-date sorting, etc. In my experience so far, people
typically don’t validate.
The general picture is this:
I use RNG because it’s much simpler than XSD, and much more powerful.
There are really practical constraints that I can model in RNG, but not
in XSD.
I’ve been looking into an alternative tack, which is to use a looser
RNG schema as the base, but embed some schematron rules. Here’s an
example:
cs-author-date.class =
[
s:rule [
context = “/cs:style"
s:assert [
test =
”@class=‘author-date’ and
cs:bibliography/cs:sort/@algorithm=‘author-date’"
“Must use author-date sorting for the author-date class.”
]
]
]
Those rules can then be extracted and used to create an XSLT that then
validates the instances based on the more tight rules. It also has the
advantage that you can write human-oriented error messages.
In general, this is an approach that places invested in XSD (like MS)
advocate (e.g. it’s a way to plug holes in XSD without having to use
RNG).
What this would mean practically for us is probably bundling some XSLTs
with the schema, and have a little shell script something like this
(though better; I don’t really know Bash!):========================
#! /usr/bin/env bash
A simple shell script to run the RELAX NG and Schematron validation.
It assumes you have xsltproc and rnv* installed.
* see http://www.davidashen.net/rnv.html
ECHO “
validating $1 …
”
rnv -q csl-alt.rnc $1
xsltproc validate.xsl $1
ECHO “
Done. If no errors reported above, then your CSL file is valid.
”
Here’s an example from another XSLT that outputs an HTML file with the
error reports, and links to the specific places in the document.
http://xml.ascc.net/schematron/1.5/report1-5/schematron-frame.html
Another advantage of this is I could easily (and automatically)
generate and XSD file should someone want it.
Any opinions?
Bruce