1 of 21

Introduction to Schematron

Fall 2019

2 of 21

Introduction to Schematron

  • Schematron vs. ODD
  • Schematron in ODD

Mechanics of Schematron

  • Namespace Issues
  • Pattern and Rule Elements
  • Context (via XPath)
  • Assert
  • Report
  • Messages / Documentation
  • Errors and warnings
  • XPath functions

Embedding Rules in your ODD

More Advanced Uses of Schematron

  • Let
  • Creating a List of Values
  • Using Values in Messages
  • Linking to your Standoff Markup

3 of 21

Introduction to Schematron

  • ODD to RelaxNG = “grammar-based”
  • Schematron = “rule-based”

4 of 21

Introduction to Schematron

  • ODD to RelaxNG = “grammar-based”
  • Schematron = “rule-based”
  • These two work together!
    • We can embed Schematron rules into our ODDs

5 of 21

Mechanics of Schematron

  • xml declaration

6 of 21

Mechanics of Schematron

  • xml declaration
  • Adding the TEI namespace is essential

7 of 21

Mechanics of Schematron

  • xml declaration
  • Adding the TEI namespace is essential

8 of 21

Mechanics of Schematron

  • xml declaration
  • Adding the TEI namespace is essential
  • <pattern> and <rule> elements
    • n.b. the “sch:” namespace is required

9 of 21

Mechanics of Schematron

  • xml declaration
  • Adding the TEI namespace is essential
  • <pattern> and <rule> elements
  • @context

10 of 21

Compare ODD and Schematron

11 of 21

Mechanics of Schematron

  • Two kinds of rules
    • <report>
      • “Send a message if the following is true.”
    • <assert>
      • “The following has to be true. Send a message if it is not true.”

12 of 21

Mechanics of Schematron

  • Messages
  • Documentation?

13 of 21

Embedding Schematron Rules in Your ODD

  • Can we write Schematron directly in the ODD?
  • <constraintSpec>
    • @ident names the rule
    • @scheme indicates “schematron” and not some other type of rule.
    • Again, namespaces are critical

14 of 21

Embedding Schematron Rules in Your ODD

  • Can we write Schematron directly in the ODD?
  • <constraintSpec>
    • @ident names the rule
    • @scheme indicates “schematron” and not some other type of rule.
    • Again, namespaces are critical

15 of 21

Embedding Schematron Rules in Your ODD

16 of 21

More Advanced Uses of Schematron

  • <sch:let>

17 of 21

More Advanced Uses of Schematron

  • <sch:let>
  • Creating a list of values

18 of 21

More Advanced Uses of Schematron

  • <sch:let>
  • Creating a list of values
  • Using values in messages

19 of 21

More Advanced Uses of Schematron

  • <sch:let>
  • Creating a list of values
  • Using values in messages
  • Linking to your standoff markup

20 of 21

Is that it?

  • No, there are many more things you can do with Schematron

Additional Resources

21 of 21

Exercises

  • Open a new Schematron file in oXygen
  • Adjust the declaration to recognize the TEI namespace
  • Associate your xml file with that Schematron file
  • Constrain something of your choosing using Schematron