A novel approach to XSLT-based Schematron validation
David Mausdmaus@dmaus.name
XML Prague 2019
Agenda
schematron in a nutshell
XSLT-based schematron validation
the challenge
three approaches
simplifications
summary
Schematron
a rule based validation language for XML documents
focus on natural-language assertions
validate arbitrary relationships in a document
key concepts designed by Rick Jelliffe in 1999
ISO-standardized in 2006, updated 2016
Key concepts
Pattern
structure in a source document specified in a schema by an ordered collection of rules
Rule
selects portions of the source document that contribute to a pattern
Assertion
natural-language assertion with an assertion test expressed as a boolean query
Example
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<pattern id="agents">
<rule context="tei:person">
<assert test="tei:persName[@type = 'preferred']">
A person element must provide a persName element
with the preferred name.
</assert>
…
</rule>
…
</pattern>
…
</schema>
XSLT-based Schematron
compile schema to stylesheet that creates a validation report
most popular way to implement Schematron validation
challenge lies in the construction of the validation stylesheet
Match rule R1 and R2 same node, different patterns
Do not match rule R3 same node, same pattern
Match same node in different patterns
xsl:apply-imports not viable
different modes one mode per pattern
xsl:next-match XSLT 2.0
Do not match same node in same pattern
override templates only works for modes per pattern
match, but remove from final report track matched (pattern, node)
match, but don't validate pass a sequence of already matched (pattern, node)