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 next >>

 

 

 


Copyright © dpunkt.verlag GmbH 2011
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "Schematron - Effiziente Business Rules für XML-Dokumente" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

dpunkt.verlag GmbH, Ringstraße 19B, 69115 Heidelberg, fon 06221-14830, fax 06221-148399, hallo(at)dpunkt.de