Skip to content

Latest commit

 

History

History

schematron

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Schematron Rulesets

This document contains instructions to run the Schematron rulesets for the Cast Voter Records and Election Results Reporting specifications.

There are multiple ways to run the Schematron rulesets. The compiled Schematron rulesets can be run with any schema-aware XSLT2 processor. Additionally the Schematron rulesets can be run directly in a tool like Oxygen. The Schematron files are located in CVR/sch and ENR/v2/sch directories of this repository, respectively.

How to run (AltovaXML)

AltovaXML is a freely available, command line based tool. AltovaXML can run a Schematron ruleset that has been compiled into an xslt, e.g. err_v2-compiled.xsl. Precompiled rulesets have been provided as part of this repository. AltovaXML is available on Windows platforms only.

There are two versions of the compiled Schematron files for each CDF. The difference is in how the validation results are provided. Those ending with _message generate messages to the standard output (i.e. screen). Those ending with _svrl generate results as XML using the SVRL format.

It is recommended to use the SVRL versions of the compiled schematron files. The SVRL versions provide not only the error messages, but contextual details around where the error occurred.

AltovaXML must be in your path or fully qualified. The default installation path for x64 based computers is C:\Program Files (x86)\Altova\AltovaXML2013 To temporarily add AltovaXML to you windows path, enter PATH=%PATH%;C:\Program Files (x86)\Altova\AltovaXML2013 in a command prompt.

  • (Optional) Change the xslt file to point to the fully qualified path of the NIST 1500-xxx schema. AltovaXML does not understand relative file system paths.
<xsl:import-schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                    xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
                    namespace="http://itl.nist.gov/ns/voting/1500-100/v2"
                    schema-location="file:///{path}"/>

The compiled Schematron files reference the xsds found on the NIST GitHub repository. Therefore, this step is optional, however, if the url of the files change or network connectivity is restricted, the transforms will not run correctly.

  • Ensure xsi:schemaLocation is specified in the instance file. Failure to do so may cause false negatives.

  • Validate the file against the schema before running schematron rules. Run the command having the form of:

{AltovaXML} /validate /in {input_file.xml}

Where {AltovaXML} is the path to the AltovaXML.exe executable, and {input_file.xml} is the path to the XML instance to validate.

This will validate against the file against the schema specified in the xsi:schemaLocation. If schema validation is successful, you will receive a message of The XML data is valid.

  • Run the command having the form of:
{AltovaXML} /xslt2 {compiled.xsl} /in {input_file.xml} [/out {output_file.xml}]

Where {AltovaXML} is the path to the AltovaXML.exe executable, {compiled.xsl} is the path to the compiled Schematron ruleset, and {input_file.xml} is the path to the XML instance to validate. If you are using the SVRL version, set the /out flag and {output_file.xml} to the path you'd like for the validation report.

PS C:\Program Files (x86)\Altova\AltovaXML2013> .\AltovaXML.exe /xslt2 C:\GitHub\CDFPrototype
\ENR\v2\sch\err_v2-compiled.xsl /in C:\GitHub\CDFPrototype\ENR\v2\sch\validation_target.xml

Expected Output

Important

Make sure the file has been validated against the XML Schema prior to running the schematron rules. Failure to do so may result in false negatives.

Message Version

If the instance file contains no errors, the command will produce a single message containing:

XSL message: Info:Ruleset is working

If the file contains errors, messages such as the one below will appear.

XSL message: PartyId (_PE2399537F-B641-E811-8104-0050568C2FC0) must point to an element of type Party

Each error is prefixed with XSL message and contains the ObjectId or other context indicating where the error occurred.

SVRL Version

Output will be directed to the file specified as {output_file.xml}, using the SVRL standard.

How to Run (Oxygen XML)

The commercial XML editor Oxygen can validate using Schematron rulesets directly. Make sure schema-aware validation is enabled and Saxon-EE is used for validation.

Schema aware option

The below video shows how to validate a XML instance using the sch ruleset.

Video instructions

These instructions were tested on Windows 10.0.17134.648 (x64) using Oxygen 21.0

Other Notes

Message XSLT versions of Schematron files were generated using the default transformer provided by Oxygen. SVRL versions were generated using the ISO Schematron Skeleton.