Overview
The Schematron
differs in basic concept from other
schema languages in that it not based on grammars
but on finding tree patterns in the parsed
document. This approach allows many kinds of structures to be
represented which are inconvenient and difficult in grammar-based
schema languages. If you know XPath or the XSLT expression
language, you can start to use
The
Schematron
immediately.
And it has free and open source implementations available.
The
Schematron
is trivially simple to
implement on top of XSLT and to customize. (There are also implementations in Python and Perl)
The Schematron
allows you to develop and mix two kinds of
schemas:
Report elements allow you
to diagnose which variant of a language you are dealing with.
Assert elements allow you to
confirm that the document conforms to a particular
schema.
The Schematron
is based on a simple action:
- First, find a context
nodes in the document (typically an element) based on XPath path
criteria;
- Then, check to see if
some other XPath expressions are true, for each of those
nodes.
The Schematron can be useful in
conjunction with many grammar-based structure-validation languages:
DTDs, XML Schemas, RELAX,
TREX, etc. Indeed,
Schematron is part of an ISO standard (DSDL: Document Schema Description
Languages) designed to allow multiple, well-focussed XML validation languages
to work together. You can even embed a Schematron
schema inside an XML Schema <appinfo> element
or inside a RELAX NG schema!