Digital humanities


Maintained by: David J. Birnbaum (djbpitt@gmail.com) [Creative Commons BY-NC-SA 3.0 Unported License] Last modified: 2020-03-02T20:36:33+0000


Test #5: Schematron

The text

This test uses a selection of 5 of 15 of Petrach's poems in Italian, which you should open from http://dh.obdurodon.org/schematron-test-Petrarch.xml. (Our file is based on one we found on Project Gutenburg, but you’ll need to use our version for the test because we’ve introduced some changes.)

The XMLO document has a root element <book> with three main child elements, <title> for the title of the book, <toc> for the table of contents, and <text> for the body of the text. In the table of contents, there are <sonnet> elements that have an @n attribute containing the sonnet number. The <text> element contains <sonnet> child elements with @n attributes, and the child elements for each sonnet are <l> elements, which correspond to individual lines. Pause now and look at that markup to see how chapters and chapter numbers are represented in the table of contents and in the main body.

The task

Your task is to write a Schematron schema that will validate the following things in both the table of contents and the body of the document:

  1. That the first sonnet number (the numerical values of the @n attributes) in both the table of contents and the body of the document is 1.
  2. The the numbers are consecutive and in the correct order, that is, that the number on each sonnet after the first is greater by 1 than the number on the preceding sonnet.
  3. That the table of contents and the text have the same number of sonnets. Since you are verifying that the @n attributes in both the table of contents and the <text> begin with 1 and proceed consecutive, if you now verify that the two sequences of <sonnet> elements have the same length, that will confirm that every entry in the table of contents corresponds to a value in the <text>, and vice versa.

You should associate your schema with your XML document instance in <oXygen/> and verify that it works by changing some of the values in the table of contents and in the body in the XML. When you are satisfied with your answer, please upload just the Schematron file (not the XML) to CourseWeb.