Share on Facebook Share on Twitter Email
Answers.com

Schematron

 

An XML schema that is used to validate an XML document. Unlike grammar-based schema languages, Schematron is made up of XPath patterns that define the tree structures and relationships. It can be used by itself or embedded within a W3C XML Schema or RELAX NG schema. The final draft of an ISO version of Schematron was made available in late 2004 and was published as an ISO standard in 2006. For more information, visit www.schematron.com. See XML schema.

Download Computer Desktop Encyclopedia to your iPhone/iTouch

Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
Wikipedia: Schematron
Top

In markup languages, Schematron is a rule-based validation language for making assertions about the presence or absence of patterns in XML trees. It is a simple and powerful structural schema language expressed in XML using a small number of elements and XPath.

In a typical implementation, the Schematron schema XML is processed into normal XSLT code for deployment anywhere that XSLT can be used.

Contents

Advantages

Because of its rule-based nature, Schematron's specificity is very strong. 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 even specify required relationships between multiple XML files.

On top of these specific rules are validation error messages expressed in natural language instead of cryptic error codes. This can make error diagnosis by end-users much easier than some other schema languages.

Uses

Schematron's elegant design of expressing constraints through a simple, XPath-based language but 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 DTDs, RELAX NG or XML Schema.
Lightweight Business Rules Engine
Schematron is not a comprehensive, Rete 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 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/IEC 19757 - Document Schema Definition Languages (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 are very simple to create using a standard XML editor or XForms application. The following is a sample schema:

<schema xmlns="http://purl.oclc.org/dsdl/schematron">
   <pattern>
      <title>Date rules</title>
      <rule context="Contract">
         <assert test="ContractDate &lt; current-date()">ContractDate should be in the past because future contracts are not allowed.</assert>
      </rule>
   </pattern>
</schema>

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 files (using XSLT) and placed in an XML Pipeline. This allows workflow process designers to build and maintain rules using standard XML manipulation tools.

For example an Apache Ant task can be used to convert Schematron rules into XSLT files.

See also

External links


 
 
Learn More
XML schema (technology)
Document Schema Definition Languages
Rick Jelliffe

Post a question - any question - to the WikiAnswers community:

 

Copyrights:

Computer Desktop Encyclopedia. THIS DEFINITION IS FOR PERSONAL USE ONLY.
All other reproduction is strictly prohibited without permission from the publisher.
© 1981-2010 The Computer Language Company Inc.  All rights reserved.  Read more
Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "Schematron" Read more