XML technologies / Schematron / Schematron introduction / Base elements

Base elements

Without HelloWorld
Instead of using the usual »HelloWorld« example, we start directly with a small Schematron schema. The Ark instance serves as a rewarding source. Firstly, we will check whether a carnivore has been accommodated with a herbivore in the same room (which is known to run contrary to the purpose of the preservation of the species):

<schema xmlns="http://purl.oclc.org/dsdl/schematron">
  <ns uri="http://www.schematron.info/ark" prefix="ark"/>
  <pattern>
    <rule context="ark:animal[@carnivore='yes']">
      <report test="parent::*/ark:animal[@carnivore='no']">
      There are carnivores and herbivores in one accommodation. 
      The animals are not a food source!
      </report>
    </rule>
  </pattern>
</schema>

The <schema> root element with the namespace "http://purl.oclc.org/dsdl/schematron" is used in order to identify the ISO Schematron language.

In the present example the five most important Schematron elements being necessary to write a simple schema are used: <schema>, <pattern> , <rule> and <report> as well as <ns>. One exception is the <ns> element for the namespace since it can be omitted in certain cases. However, it is essential for our example because the Ark instance has been assigned to a namespace.

 

 

 

back to top