validation

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

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.

[…]

Another advantage of this is I could easily (and automatically)
generate and XSD file should someone want it.

Any opinions?

It might make sense to provide a web validator instead of or in addition to
the script, since it would make things much easier for Windows users.

RNG vs. XSD isn’t much of an issue for me (although obviously, RNG compact
syntax is easier to read), so I don’t think the ability to generate an XSD
is a critical feature, but I realize that it could be for some people.

Simon

It might make sense to provide a web validator instead of or in
addition to
the script, since it would make things much easier for Windows users.

Yeah, I was thinking the same.

RNG vs. XSD isn’t much of an issue for me (although obviously, RNG
compact
syntax is easier to read),

Yup, and a joy to write too!

so I don’t think the ability to generate an XSD
is a critical feature, but I realize that it could be for some people.

I feel the same of course.

I got what I think is some good advice on the RNG list, which is to do
a lot of the constraints in RELAX NG (works well for people using
validating editors like nXML or oXygen), but then add some Schematron
rules on top.

Conversion to XSD then becomes pretty easy because I can write a little
customization schema that overrides the more complex restrictions and
simplifies it. The schematron rules are thus independent, and could be
coupled with the XSD to get proper validation.

Come to think of it, assuming I can do all of what I want in RNG (and I
can), I can just put the schematron stuff in the customization schema

… which looks like this, BTW:

include “csl-alt.rnc” {
cs-citationstyle =
element cs:style {
attribute class { cs-classes },
cs-info,
cs-terms?,
cs-defaults,
cs-citation?,
cs-bibliography?
}
}
cs-classes = “author-date” | “number” | “label” | “annotated” | “note”

Bruce