Schematron Validation How To
Schematron is an ISO Standard and a technology heavily based on XPath und XSLT. For general information about schematron see http://schematron.com/
Requirements
To do a schematron validation of a VEC File the following requirements are necessary:
- A native schematron validator (e.g. integrated in a xml editor) or a XSLT 2.0 Processor (e.g. Saxon).
- Validator / Processor must be a schema aware processor (SA). This is because many of the schematron rules defined for the VEC are defined on the meta model of the VEC and therefore require the type information of the xml elements that are validated.
- The schematron skeleton, available at https://github.com/Schematron/schematron if you are using an XSLT processor to validate.
Validation
The following steps are explaining the validation procedure when using the ISO schematron skeleton. For other validators similar steps are necessary. Schematron validation with the skeleton consists of two phases.
In the first, the schema is compiled into a XSLT stylesheet. This has only to be done once per schema. In the second phase, the resulting XSLT stylesheet is applied to the file that should be validated. The result of this is an XML file describing the validation errors (normally in Schematron Validation Reporting Language (SVRL).
For the compilation of the schema, the following steps are necessary:
- Ensure schema aware XSLT processing is turned on (e.g. by using Saxon EE).
- Ensure that the
import-schema
in the VEC schematron schema is pointing to a valid URL of the corresponding XML Schema.
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding"xslt2">
<xsl:import-schema xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
schema-location="VEC%201.1.3-strict.xsd"
namespace="http://www.prostep.org/ecad-if/2011/vec"/>
<sch:ns prefix="vec" uri"http://www.prostep.org/ecad-if/2011/vec"/>
- Normally the compilation pipeline of the ISO skeleton consists of the three XSLT scripts:
iso_dsdl_include.xsl
,iso_abstract_expand.xsl
andiso_svrl_for_xslt2.xsl
. Since we currently do not use partial schemas and abstract patterns, the first two can be omitted. So only the processing withiso_svrl_for_xslt2.xsl
is necessary. Here it is important to turn on the parameterallow-foreign
, because otherwise the VEC schema information will not be imported. - The resulting XSLT script can be used to validate any VEC file of the given schema version.