Schematron
Encyclopedia
In markup languages, Schematron is a rule-based validation
XML Validation
XML validation is the process of checking a document written in XML to confirm that it is both "well-formed" and also "valid" in that it follows a defined structure. A "well-formed" document follows the basic syntactic rules of XML, which are the same for all XML documents...

 language for making assertions about the presence or absence of patterns in XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

 trees. It is a structural schema language expressed in XML using a small number of elements and XPath
XPath
XPath is a language for selecting nodes from an XML document. In addition, XPath may be used to compute values from the content of an XML document...

.

In a typical implementation, the Schematron schema XML is processed into normal XSLT
XSLT
XSLT is a declarative, XML-based language used for the transformation of XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one. The new document may be serialized by the processor in standard XML syntax or in another format,...

 code for deployment anywhere that XSLT can be used.

Schematron is capable of expressing constraints in ways that other XML schema languages like XML Schema and DTD
Document Type Definition
Document Type Definition is a set of markup declarations that define a document type for SGML-family markup languages...

 cannot. For example, it can require that the content of an element be controlled by one of its siblings. Or it can request or require that the root element, regardless of what element that is, must have specific attributes. Schematron can also specify required relationships between multiple XML files.

Constraints and content rules may be associated with "plain-English" validation error messages, allowing translation of numeric Schematron error codes into meaningful user error messages.

Uses

Schematron's design of expressing constraints through an XPath-based language that can be deployed as XSLT code, make it practical for applications such as the following:

Adjunct to Structural Validation: by testing for co-occurrence constraints, non-regular constraints, and inter-document constraints, Schematron can extend the validations able to be expressed in languages such as DTD
Document Type Definition
Document Type Definition is a set of markup declarations that define a document type for SGML-family markup languages...

s, RELAX NG
RELAX NG
In computing, RELAX NG is a schema language for XML, based on Murata Makoto's RELAX and James Clark's TREX. A RELAX NG schema specifies a pattern for the structure and content of an XML document...

 or XML Schema.

Lightweight Business Rules Engine: Schematron is not a comprehensive, Rete
Rete algorithm
The Rete algorithm is an efficient pattern matching algorithm for implementing production rule systems. The Rete algorithm was designed by Dr Charles L. Forgy of Carnegie Mellon University, first published in a working paper in 1974, and later elaborated in his 1979 Ph.D. thesis and a 1982 paper...

 rules engine, but it can be used to express rules about complex structures with an XML document.

XML Editor Syntax Highlighting Rules: XML Editors use Schematron rules to conditionally highlight XML files for errors.

Versions

Schematron was invented by Rick Jelliffe
Rick Jelliffe
Richard Alan Jelliffe is an Australian programmer and standards activist , particularly associated with web standards, markup languages, internationalization and schema languages. He is the founder and Chief Technical Officer of Topologi Pty. Ltd, an XML tools vendor in Sydney...

 at Academia Sinica Computing Centre, Taiwan. He described Schematron as "a feather duster to reach the parts other schema languages cannot reach".

The most common versions of Schematron are:
  • Schematron 1.0 (1999)
  • Schematron 1.3 (2000): this version used the namespace http://xml.ascc.net/schematron/. It was supported by an XSLT implementation with a plug-in architecture.
  • Schematron 1.5 (2001): this version was widely implemented and still found.
  • Schematron 1.6 (2002): this version was the base of ISO Schematron and obsoleted by it
  • ISO Schematron (2006): this version regularizes several features, and provides an XML output format SVRL. It uses the new namespace http://purl.oclc.org/dsdl/schematron
  • ISO Schematron (2010): this proposed version adds support for XSLT2 and arbitrary properties

Schematron as an ISO Standard

Schematron has been standardized to become part of : ISO
International Organization for Standardization
The International Organization for Standardization , widely known as ISO, is an international standard-setting body composed of representatives from various national standards organizations. Founded on February 23, 1947, the organization promulgates worldwide proprietary, industrial and commercial...

/IEC
International Electrotechnical Commission
The International Electrotechnical Commission is a non-profit, non-governmental international standards organization that prepares and publishes International Standards for all electrical, electronic and related technologies – collectively known as "electrotechnology"...

 19757 - Document Schema Definition Languages
Document Schema Definition Languages
Document Schema Definition Languages is a framework within which multiple validation tasks of different types can be applied to an XML document in order to achieve more complete validation results than just the application of a single technology....

 (DSDL) - Part 3: Rule-based validation - Schematron.

This standard is available free on the ISO Publicly Available Specifications list. Paper versions may be purchased from ISO or national standards bodies.

Schemas that use ISO/IEC FDIS 19757-3 should use the following namespace:


http://purl.oclc.org/dsdl/schematron

Sample Rule

Schematron rules can be created using a standard XML editor or XForms
XForms
XForms is an XML format for the specification of a data processing model for XML data and user interface for the XML data, such as web forms...

 application. The following is a sample schema:




Date rules

ContractDate should be in the past because future contracts are not allowed.





This rule checks to make sure that the ContractDate XML element has a date that is before the current date. If this rule fails the validation will fail and an error message which is the body of the assert element will be returned to the user.

Implementation

Schematron source files are usually transformed into XSLT
XSLT
XSLT is a declarative, XML-based language used for the transformation of XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one. The new document may be serialized by the processor in standard XML syntax or in another format,...

 files (using XSLT) and placed in an XML Pipeline
XML pipeline
In software, an XML Pipeline is formed when XML processes, especially XML transformations and XML validations, are connected together....

. This allows workflow process designers to build and maintain rules using standard XML manipulation tools.

For example an Apache Ant
Apache Ant
Apache Ant is a software tool for automating software build processes. It is similar to Make but is implemented using the Java language, requires the Java platform, and is best suited to building Java projects....

 task can be used to convert Schematron rules into XSLT files.

See also

  • XML Schema Language Comparison
    XML Schema Language Comparison
    An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntax constraints imposed by XML itself. There are several different languages available for specifying an XML...

     - Comparison to other XML Schema languages.
  • Service Modeling Language
    Service Modeling Language
    Service Modeling Language ' and Service Modeling Language Interchange Format ' are a pair of XML-based specifications created by leading information technology companies that define a set of XML instance document extensions for expressing links between elements, a set of XML Schema extensions for...

    - Service Modeling Language uses Schematron.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK