Schematron
The Schematron is a schema language for validation of content and structure of XML documents. The implementation of the language is implemented through XSL transformations, so does not require any specific implementation, such as is the case with most other document structure definition language.
Schematron was developed by Rick Jelliffe at the Academia Sinica Computing Centre in Taipei, Taiwan in 1999. Since May 2006 Schematron 1.6 is registered as an official ISO / IEC 19757-3:2006 standard under the number ( called ISO Schematron ).
Introduction
Unlike, for example DTD or XML schema Schematron not used to define, but for validation of content in XML documents. It does not use a formal grammar, but finds patterns in the document structure. Thereby, it is possible to define rules which would not be possible with conventional schema languages that are based on grammars. However, Schematron should be understood primarily as a supplement, not as a competitor to other schema languages.
Possible applications include complex rules that express dependencies between different parts of the document tree or require dynamic calculations.
Concept and syntax
A Schematron schema consists essentially of an XML document with different validation rules, in each of which a context node is determined, on which representations and reports formulated to be tested later.
The following example shows a Schematron 1.5 schema:
- An optional element
describing the schema - Any number of < ns prefix = "? *? *? " uri = "? *? *? " / > Elements where namespace (uri ) and their prefixes ( prefix ) for use in XPath expressions are declared,
as a container with a description (name) for more - elements, context, an XPath expression is used to define the environment in which the following two elements are executed: to formulate an assurance, together with an error message for the case that the in test formulated using XPath test fails, or - ( in the example does not use )
to formulate an assurance, together with a message text in the event that the test is successful.
Basically you put in Schematron determine the success or failure messages themselves, which appear at the end as a result of the validation.
Operation
Formulated in the scheme for carrying out the tests, it is necessary to use a Schematron implementation. One possible implementation is an XSL stylesheet, which in turn generates an XSL stylesheet from the given scheme, with which then the document to be tested is transformed:
At the end, depending on the type of Schematron implementation used, a text or XML document that contains the results of the test ( reports of successful
The reference implementation is specifically designed modularly, so that one can use, for example, one of the standard text style sheets to create a simple text output. The Schematron "core" is only designed to search error and to collect success stories. A separate extended stylesheet could then, for example, create a self -defined XML format with error messages, which is processed by a software first, to determine whether validation errors have occurred at all, before they are automatically recorded and displayed to the user.