Schematron Report Customization

Markup UK 2020 Webinars

DOI: 10.5281/zenodo.3890890

Who am I?

  • David Maus
  • head of development @ State- and University Library Hamburg
  • author of SchXslt, a modern XSLT-based Schematron implementation
  • Contact:
    dmaus@dmaus.name https://dmaus.name

This webinar's repository

Repository content

docs/
presentation slides
examples/
examples
schxslt/
schematron implementation (SchXslt 1.4.5)
webinar.xpr
oXygen project file with transformation scenarios for the examples

Report customization use cases

  • use a less verbose variant of a SVRL report
  • use a more verbose variant of a SVRL report
  • use a custom report format
  • create an annotated document instance

XSLT-based implementations

SchXslt
github.com/schxslt/schxslt
Skeleton
github.com/schematron/schematron
Skeleton variants
modified versions of the Skeleton
Two stages of an XSLT-based implementation
Customize the report by customizing the compiler

Compiler customization

Parts of the validation stylesheet are created by named templates

SchXslt Callback API

schxslt-api:active-pattern instructions for when a pattern is activated
schxslt-api:fired-rule instructions for when a rule matches the context node
schxslt-api:shadowed-rule instructions for when a rule does not match the context node because the node was matched by a previous rule of the same pattern
schxslt-api:failed-assert instructions for when the expression in the @test attribute of an assertion evaluated to false
schxslt-api:succesful-report instructions for when the expression in the @test attribute of a report evaluated to true
schxslt-api:validation-stylesheet-body-top-hook instructions that go to the top of the validation stylesheet
schxslt-api:validation-stylesheet-body-bottom-hook instructions that go to the bottom of the validation stylesheet
schxslt-api:report create the final report

Using the callback API

  • customization via the callback API utilizes the import mechanism of XSLT
  • if the compiler calls a template, the XSLT processor selects the one with the highest import precedence
  • to customize the report
    1. import the compiler stylesheet
    2. override the API templates
    3. use your stylesheet to compile the validation stylesheet

Example 1: Built-in compiler for SVRL report

schxslt/2.0/compile-for-svrl.xsl

Import precedence in example 1

Example 2: Custom SVRL

examples/example-2

Create a SVRL report but without information about active patterns, fired, and shadowed rules.

Import precedence in example 2

Example 3: Custom report

examples/example-3

Use a custom report format.

                            start = element report {
    element failed-assert {
        attribute id { xs:ID }
      & attribute timestamp { xs:datetime }
      & empty
    }*
}
                        

Example 4: Annotated document

examples/example-4

Annotate elements of the document instance.

Limitations

  1. no straightforward way to create a nested report
  2. requires access to the URI of the compiler stylesheet
Schematron Mailinglist
schematronist.org
Slack Channel
xmlcom.slack.com