Before beginning this assignment, please thoroughly read our introduction to Schematron. This tutorial will be very useful to you during this assignment and the Schematron Exercise 2. To begin this assignment, you will need to open a new Schematron document in <oXygen/> under File → New → New Document → (scroll to Schematron in the alphabetized list) → Schematron. Once opened, you will keep the default xml line at the top, but you will delete everything from <sch:schema> down. You will then replace this with:

<schema xmlns:sch="" queryBinding="xslt2"

You will be writing your Schematron inside the <schema> root element.

Analysis of the task


For this assignment, we are looking at votes for what place the Pitt-Greensburg DH Class will go for Spring Break. The options include: New York City, Mexico, London, and Rome. Each place gets between 0% and 100% of the votes. Assume here that this is the final voting poll, and there are no other options. This means that when you add the four percentages together, the result must be exactly 100%. Also assume that this is recording the already calculated percentage of the votes, not the raw count of the votes. All of these percentages are to be integer values.

Here is a Relax NG schema for the results of the Spring Break votes:

start = results
results = element results {place+}
place = element place {name, xsd:int}
name = attribute name {"NYC" | "Mexico" | "London" | "Rome"}

Here is a sample XML document that is valid against the above schema:

    <place name="NYC">24</place>
    <place name="Mexico">34</place>
    <place name="London">12</place>
    <place name="Rome">30</place>

Note: You will want to copy and paste this XML into an XML document so you can associate your Schematron and make sure that it is working correctly.

Our Relax NG schema is a little sloppy and could have been better written (as we will discuss below). It lets us set a rule that the content of the element <place> must be a number (or xsd:int for integer), but the rule isn’t really good enough as we will see from the from the following example:

<place name="NYC">27</place>
<place name="Mexico">39</place>
<place name="London">15</place>
<place name="Rome">12</place>

Do you see the problem? The four percentage values only total 93%! No matter how good our coding is, it is not possible to keep this type of error from happening by using Relax NG alone. That is why we use Schematron.


Your task is to write a Schematron schema that makes sure the four percentages always equal 100%. Test your results by creating the Relax NG schema, your Schematron, and a sample XML document that is validated against both of the schemas in <oXygen/>. Play with the XML a little bit to make sure your Schematron is firing by entering correct and incorrect values into the XML. [You can stop here for a complete assignment or complete the optional part of this assignment for more practice, which may enhance your grade.]

OPTIONAL: The following errors could have been corrected by writing a better Relax NG schema, but to help you learn how to use Schematron schemas, try it in Schematron:


Upload your completed Schematron schema on Courseweb (and follow our standard filenaming conventions for homework assignments uploaded to Courseweb).