We have all been through this: Your documents passed all reviews, any corrections were entered to the best of your knowledge. The document returns from printing. The first person to look at it instantly spots at least three mistakes. In fact exactly the same ones that all those involved in the process had already overlooked the last time.
Or: Your service provider delivers the documents created by him shortly before editorial deadline and again not all specifications from the editorial style guide have been observed.
With the new Schematron module in SCHEMA ST4 2012 R2 it is possible to phrase and manage so-called “Business Rules” conveniently. XML documents can automatically be checked for content and structure before final production— or of course at any other point.
Schematron may sound like SCHEMA, but there is no connection: Schematron is a schema language for context-related validation of XML documents that was developed by Rick Jelliffe at the Academia Sinica Computing Centre in Taipeh, Taiwan in 1999. Since May 2006 Schematron has been an official ISO/IEC Standard standard (ISO/IEC 19757-3:2006).
For the definition of Schematron rules only XPath knowledge is necessary. The language is implemented via XSL transformations and therefore does not require an adaptation of the DTD or the XML schema. With Schematron large parts of an editorial style guide can be implemented.
What Does the Rule Syntax Look Like?
For general use the rules look like this:
Where to Get the XPath Expressions for the Context and the Conditions?
Not everybody masters XPath so as to be able to phrase rules straight away by himself. There are several approaches: Academical: acquiring the basics with the help of an informative book and then applying the attained knowledge. Pragmatical: Copying and adapting example rules that carry out similar tests. Exactly how the elements to be tested need to be addressed in the Schematron rules can for example be concluded from a (test) XML production. In the standard ST4 DTD one can find there among others the list elements
<li> within ordered
<ol> and unordered
<ul> lists, paragraphs
<p>, inline formats like italic
<i> and bold
<b>, information classes like “class=InfoType02” or node classes like “type=TextNode”.
Example: A list needs to contain between 2 and 7 list items
How Can the Rules be Entered into the System?
The rules are created, shown, managed and selected for testing in the Rich or Architect Client in a specific viewlet. Execution is also possible in the Thin Client.
ST4 offers two modes for creating rules: the auto mode and the expert mode. In the auto mode you fill the respective fields and ST4 creates the actual Schematron rule, in the expert mode you directly enter the rule according to the syntax. The rules are classified via their properties according to the seriousness of the violation of the rule:
How are the Rules Applied?
In the ST4 Reporting Center the corresponding Schematron report can be found: mark the project in the project tree, in the report select the desired variant filter (if available) and the language to be tested. In the Schematron viewlet mark the rule or the set of rules and in the report start the test via the corresponding button.
One click on the respective link shows the node that caused the violation of the rule.
Other than for example DTD or XML schema, Schematron is not used for the definition but for the validation of content in XML documents. It does not use formal grammar but detects patterns in the document structure. Thus it is possible to define rules which could not be done in this manner with schema languages that are based on grammar rules. Still Schematron should be regarded as an addition not a competition to other schema languages.