Deriving Schematron from SBVR constraints for ISO 19109 compliant schema

The process of deriving ISO Schematron code from constraints expressed in SBVR for an ISO 19109 compliant application schema consists of four steps, only two of which are required:

  1. Loading the conceptual schemas (required)
  2. Loading the constraints from an excel file (optional)
  3. Parsing the constraints to First Order Logic constraints/expressions (can be omitted if step 2 has been omitted)
  4. Translate the FOL constraints to ISO Schematron (required)

NOTE: it is possible to have all constraints in the model itself. Once the model has been loaded they will be parsed to FOL while the model is being postprocessed.  In that case, the transformations to load them from an Excel file and subsequently parse them would not be applicable.

The OGC Testbed 11 Aviation – Guidance on Using SBVR Engineering Report describes these steps in more detail.

From a configuration point of view, the following is important (a complete example configuration is given at the end of this page):

  1. Loading the conceptual schemas:
    1. ensure that constraint checking is not disabled, and that the input parameter ‘folConstraintTypeRegex’ is set to SBVR.
    2. more details on these configuration parameters can be found on the input element page
  2. Loading the constraints from an excel file
    1. provide the correct file location and ensure that the file is structured correctly (an example is available here)
    2. more details on the configuration of the according transformation can be found on the Constraint Loader page
  3. Parsing the constraints to First Order Logic constraints/expressions
    1. more details on the configuration of the according transformation can be found on the First Order Logic Constraint Parser page
  4. Translate the FOL constraints to Schematron
    1. ensure that ‘TargetXmlSchema’ is used as configuration element
    2. ensure that the ‘defaultEncodingRule’ identifies an encoding rule that contains the conversion rules with which the XML Schema representation of the application schema can be created (important to identify the XML structure for which Schematron must be created)
    3. more details on the configuration of the according target can be found on the FOL to Schematron page

Example Configuration

With loading constraints from external source (Excel file)

<ShapeChangeConfiguration
  xmlns="http://www.interactive-instruments.de/ShapeChange/Configuration/1.1"
  xmlns:sc="http://www.interactive-instruments.de/ShapeChange/Configuration/1.1"
  xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.interactive-instruments.de/ShapeChange/Configuration/1.1 https://shapechange.net/resources/schema/ShapeChangeConfiguration.xsd">
  <input id="INPUT">
    <parameter name="inputModelType" value="EA7"/>
    <parameter name="inputFile" value="./sbvr2schematron.eap"/>
    <parameter name="appSchemaNameRegex" value="AppSchema"/>
    <parameter name="publicOnly" value="true"/>
    <parameter name="checkingConstraints" value="enabled"/>
    <parameter name="folConstraintTypeRegex" value="SBVR"/>
    <parameter name="sortedSchemaOutput" value="true"/>
    <xi:include href="https://shapechange.net/resources/config/StandardAliases.xml"/>
  </input>
  <log>
    <parameter name="reportLevel" value="INFO"/>
    <parameter name="logFile" value="./log.xml"/>
  </log>
  <transformers>
    <Transformer
      class="de.interactive_instruments.ShapeChange.Transformation.Constraints.ConstraintLoader"
      id="step1" input="INPUT" mode="enabled">
      <parameters>
        <ProcessParameter name="constraintExcelFile" value="./constraint_informations.xlsx"/>
      </parameters>
    </Transformer>
    <Transformer
      class="de.interactive_instruments.ShapeChange.Transformation.Constraints.FolConstraintParsing"
      id="step2" input="step1" mode="enabled"/>
  </transformers>
  <targets>
    <TargetXmlSchema
      class="de.interactive_instruments.ShapeChange.Target.FOL2Schematron.FOL2Schematron"
      inputs="step2" mode="enabled">
      <targetParameter name="outputDirectory" value="./results/sch"/>
      <targetParameter name="defaultEncodingRule" value="iso19136_2007"/>
      <xi:include href="https://shapechange.net/resources/config/StandardRules.xml"/>
      <xi:include href="https://shapechange.net/resources/config/StandardNamespaces.xml"/>
      <xi:include href="https://shapechange.net/resources/config/StandardMapEntries.xml"/>
    </TargetXmlSchema>
  </targets>
</ShapeChangeConfiguration>

With constraints directly defined in the model

<ShapeChangeConfiguration
  xmlns="http://www.interactive-instruments.de/ShapeChange/Configuration/1.1"
  xmlns:sc="http://www.interactive-instruments.de/ShapeChange/Configuration/1.1"
  xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.interactive-instruments.de/ShapeChange/Configuration/1.1 https://shapechange.net/resources/schema/ShapeChangeConfiguration.xsd">
  <input>
    <parameter name="inputModelType" value="EA7"/>
    <parameter name="inputFile" value="./sbvr2schematron.eap"/>
    <parameter name="appSchemaNameRegex" value="AppSchema"/>
    <parameter name="publicOnly" value="true"/>
    <parameter name="checkingConstraints" value="enabled"/>
    <parameter name="folConstraintTypeRegex" value="SBVR"/>
    <parameter name="sortedSchemaOutput" value="true"/>
    <xi:include href="https://shapechange.net/resources/config/StandardAliases.xml"/>
  </input>
  <log>
    <parameter name="reportLevel" value="INFO"/>
    <parameter name="logFile" value="./log.xml"/>
  </log>
  <targets>
    <TargetXmlSchema
      class="de.interactive_instruments.ShapeChange.Target.FOL2Schematron.FOL2Schematron" mode="enabled">
      <targetParameter name="outputDirectory" value="./results/sch"/>
      <targetParameter name="defaultEncodingRule" value="iso19136_2007"/>
      <xi:include href="https://shapechange.net/resources/config/StandardRules.xml"/>
      <xi:include href="https://shapechange.net/resources/config/StandardNamespaces.xml"/>
      <xi:include href="https://shapechange.net/resources/config/StandardMapEntries.xml"/>
    </TargetXmlSchema>
  </targets>
</ShapeChangeConfiguration>