Schematron - SAA-SDT/TS-EAS-subteam-notes GitHub Wiki

Introduction

With EAD3 published in 2015 extended validation using Schematron was introduced. The Schematron rules have been further extended and refined during the development of EAC-CPF version 2.0. For EAD3 the Schematron is currently placed in the EAD3 repository. For EAC-CPF version the Schematron is placed in the EAS Schematron repository.

Schematron

Both XML-schema and RNG-schema have limitations in which types of validations it is possible to carry out. For example it is not possible to do condition based validation using just the schema languages. To overcome this Schematron was developed. Schematron is an ISO standard available here: http://schematron.com/ . If you are new to Schematron this is a good resource: http://www.mulberrytech.com/papers/schematron-Philly.pdf

EAD3 and Schematron

EAD3 is based on using Schematron for aiding with validation. When using EAD3 the best option is to have the schema saved locally and with it you need to have the folder with the Schematron and its extending documents which are placed in its own folders. The Schematron document is used for validations of the country code when the ISO standard is used, dates when the ISO standard is used as well as if an attribute has it value set to the value “other” that the accompanying other-attribute is used. Your own rules are put in its own Schematron document.

EAC-CPF version 2 and Schematron

For a full description of the validations carried out please read the detailed description in the EAS Schematron repository

Schematron and XML validation

Due to the extension of the validation with Schematron validation you need to make sure that the validation takes place. Not all validators manage to do this automatically, you may need to do some settings but it all depends on the validator. At the same time, it differs with how the Schematron rules are called by the XML-document. If you are using the RNG-schema, the schema itself has a call of the Schematron rules. This means that the schema needs to be updated with the call of your Schematron rules. If you are using the XML-schema it is not possible to call the Schematron rules within the schema instead the validator needs to have the setting for using the Schematron document. How to do it depends on the validator you are using.

Your own Schematron rules

You put your rules in its own Schematron document which with the added line calls the Schematron documents which is being extended. Replace “Name of Schematron document” with the name of the Schematron document. For the calling of the EAD3 validation extending information XML-documents its important to have them all in the same catalog as you have downloaded them from either http://www.loc.gov/ead/ead3schema.html or https://github.com/SAA-SDT/EAD3 and https://github.com/SAA-SDT/EAD3/tree/master/schematron .

Image showing the linking between scheamtron documents

On the left we have the extension document ”FGS_ead3.sch”. which extends the validation rules from ”ead3.sch” which in its turn uses value lists created by ISO called in the code.

An example

This is an example of the extension Schematron document with the extra rules I have decided needs to be true and tested for my EAD3 documents.

<extends href="ead3.sch"/>

<!-- Here follows all the rules for the own adaption of EAD3-->
<pattern id="anpassning">
    <rule context="ead:control">
        <!-- In the control element we check that the attributes @base and @audience follows the adaption rules -->
        <!-- First a assert test so the @base is present. If its not present its an error -->
        <!-- Second a report test to see if the @audience is present. This is just information -->
        <assert test="exists(@base)">Error message, the attribute base must be present in the control element</assert>
        <report test="exists(@audience)">Contol message, the attribute audience is present in the control element</report>
    </rule>
</pattern>
⚠️ **GitHub.com Fallback** ⚠️