Compiled Schematron

The Schematron Schema is compiled into an XSLT using a customized version of the Schematron skeleton implementation [10]. The sekeleton implementation needed to be adjusted for two reasons:

  1. We also wanted to use attributes as rule context.[11]

  2. We wanted to provide a more human readable version of the location where the error occurs.

Given the the following XML file…

<passenger>
    <name>Jane Grant</name>
    <cabin-bag>
        <weight>11</weight>
    </cabin-bag>
 </passenger>

…the target output of the compiled Schematron XSLT is an XML document that follows the structure of the Schematron Validation Report Language. A failed Schematron assert would result in the following SVRL:

<svrl:failed-assert 
  test="$bag-weight le 8"
  id="assert-c1-1"
  see="http://www.cabin-bag.info/c1"
  location="/passenger[1]/cabin-bag[1]/weight[1]"
  subcheck:alternativeLocation="/passenger/cabin-bag/weight">
   <svrl:text>
     The weight of cabin luggage is 8kg or less.
    </svrl:text>
   <svrl:diagnostic-reference 
      diagnostic="diag-weight-8">
       The cabin luggage of Jane Grant exceeded 
       the maximum weight allowance by 3kg. 
       Pack lighter!
   </svrl:diagnostic-reference>
</svrl:failed-assert>

The reference to the documentation of the constraint in the constraint.xml is kept in a @see attribute.



[10] see https://github.com/Schematron/schematron

[11] see also the discussion on issues https://github.com/Schematron/schematron/issues/44 and https://github.com/Schematron/schematron/issues/29 and pull request https://github.com/Schematron/schematron/pull/41