# Deriving Schematron from AIXM Business Rules

The process of deriving Schematron code from AIXM business rules expressed in SBVR consists of five steps:

1. Loading the conceptual schemas

2. Merging AIXM core and extension schemas

3. Loading AIXM business rules from an excel file

4. Parsing the rules to First Order Logic constraints/expressions

5. Translate the FOL constraints to Schematron

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 the input parameter 'isAIXM' is true, that constraint checking is not disabled, and that the input parameter 'folConstraintTypeRegex' is set to SBVR.

   2. ensure that PackageInfo elements are configured that identify the relevant AIXM schemas together with their target namespaces and preferred XML namespace prefixes.

   3. set stereotype aliases to map the stereotypes used by AIXM schema to the well-known stereotypes that ShapeChange uses internally

   4. more details on these configuration parameters can be found on the input element page

2. Merging AIXM core and extension schemas

   1. ensure that the 'coreSchemaTargetNamespace' parameter is set correctly (unless the default value applies, in which case the parameter can be omitted)

   2. more details on the configuration of the according transformation can be found on the AIXM Schema Merger page

3. Loading AIXM business rules 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

4. Parsing the rules 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

5. Translate the FOL constraints to Schematron

   1. ensure that 'TargetXmlSchema' is used as configuration element

   2. ensure that the 'defaultEncodingRule' identifies a custom encoding rule that contains the conversion rules 'rule-all-cls-aixmDatatype' and 'rule-all-prop-uomAsAttribute', on top of the ISO 19136 conversion rules

   3. more details on the configuration of the according target can be found on the FOL to Schematron page

## 1. Example Configuration

      1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73

      <?xml version="1.0" encoding="UTF-8"?>
    <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="./AIXM.eap"/>
        <parameter name="appSchemaNameRegex" value="AIXM|Digital NOTAM Event Specification"/>
        <parameter name="publicOnly" value="true"/>
        <parameter name="checkingConstraints" value="enabled"/>
        <parameter name="folConstraintTypeRegex" value="SBVR"/>
        <parameter name="sortedSchemaOutput" value="true"/>
        <parameter name="isAIXM" value="true"/>
        <packages>
          <PackageInfo ns="http://www.aixm.aero/schema/5.1" nsabr="aixm" packageName="AIXM"
            version="5.1" xsdDocument="aixm.xsd"/>
          <PackageInfo ns="http://www.aixm.aero/schema/5.1/event" nsabr="event"
            packageName="Digital NOTAM Event Specification" version="1.0" xsdDocument="event.xsd"/>
        </packages>
        <parameter name="excludedPackages"
          value="ISO 19107  Geometry, ISO 19115 Metadata, ISO 19136, XMLSchemaDatatypes"/>
        <xi:include href="https://shapechange.net/resources/config/StandardAliases.xml"/>
        <stereotypeAliases>
          <StereotypeAlias alias="object" wellknown=""/>
          <StereotypeAlias alias="message" wellknown=""/>
          <StereotypeAlias alias="choice" wellknown="Union"/>
          <StereotypeAlias alias="feature" wellknown="FeatureType"/>
          <StereotypeAlias alias="extension" wellknown="AIXMExtension"/>
        </stereotypeAliases>
      </input>
      <log>
        <parameter name="reportLevel" value="INFO"/>
        <parameter name="logFile" value="./aixm_log.xml"/>
      </log>
      <transformers>
        <Transformer class="de.interactive_instruments.ShapeChange.Transformation.AIXM.AIXMSchemaMerger"
          id="step1" input="INPUT" mode="enabled">
          <parameters>
            <ProcessParameter name="coreSchemaTargetNamespace" value="http://www.aixm.aero/schema/5.1"/>
          </parameters>
        </Transformer>
        <Transformer
          class="de.interactive_instruments.ShapeChange.Transformation.Constraints.ConstraintLoader"
          id="step2" input="step1" mode="enabled">
          <parameters>
            <ProcessParameter name="constraintExcelFile"
              value="./AIXM_business_rules.xlsx"/>
          </parameters>
        </Transformer>
        <Transformer
          class="de.interactive_instruments.ShapeChange.Transformation.Constraints.FolConstraintParsing"
          id="step3" input="step2" mode="enabled"/>
      </transformers>
      <targets>
        <TargetXmlSchema
          class="de.interactive_instruments.ShapeChange.Target.FOL2Schematron.FOL2Schematron"
          inputs="step3" mode="enabled">
          <targetParameter name="outputDirectory" value="./results/sch"/>
          <targetParameter name="defaultEncodingRule" value="aixm"/>
          <rules>
            <EncodingRule extends="iso19136_2007" name="aixm">
              <rule name="rule-all-cls-aixmDatatype"/>
              <rule name="rule-all-prop-uomAsAttribute"/>
            </EncodingRule>
          </rules>
          <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>