Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Schematron
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Rule-based validation language for XML}} '''Schematron''' is a rule-based [[XML validation|validation language]] for making assertions about the presence or absence of patterns in [[XML]] trees. It is a structural schema language expressed in XML using a small number of elements and [[XPath]] languages. In many implementations, Schematron XML is processed into [[XSLT]] 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 (W3C)|XML Schema]] and [[Document Type Definition|DTD]] 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" (or any language) validation error messages, allowing translation of numeric Schematron error codes into meaningful user error messages. Users of Schematron define all the error messages themselves.<ref>{{Cite book |last=Siegel |first=Erik |title=Schematron: a language for validating XML |date=2022 |publisher=XML Press |isbn=978-1-937434-81-6 |location=Denver, CO}}</ref> The current [[International Organization for Standardization|ISO]] recommendation is ''Information technology, Document Schema Definition Languages (DSDL)'', Part 3: ''Rule-based validation, Schematron'' (ISO/IEC 19757-3:2020). == Uses == Constraints are specified in Schematron using an XPath-based language that can be deployed as XSLT code, making 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 that can be expressed in languages such as [[Document Type Definition|DTD]]s, [[RELAX NG]] or [[XML Schema (W3C)|XML Schema]].<ref>{{Cite journal|title=Schematron - More useful than you'd thought|first=Philip|last=Fennell|date=June 2014|journal=XML London 2014|doi=10.14337/XMLLondon14.Fennell01|pages=103β112|isbn=978-0-9926471-1-7|url=http://xmllondon.com/2014/presentations/fennell/|doi-access=free}}</ref> ; Lightweight Business Rules Engine: Schematron is not a comprehensive, [[Rete algorithm|Rete]] rules engine, but it can be used to express rules about complex structures with an XML document. ; XML Editor Syntax Highlighting Rules: Some XML editors use Schematron rules to conditionally highlight XML files for errors. Not all XML editors support Schematron. == Versions == Schematron was invented by [[Rick Jelliffe]] while 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. * [http://xml.ascc.net/schematron/ Schematron 1.5] (2001): This version was widely implemented and can still be found. * [http://xml.ascc.net/resource/schematron/Schematron2000.html Schematron 1.6] (2002): This version was the base of ISO Schematron and obsoleted by it. * [http://standards.iso.org/ittf/PubliclyAvailableStandards/index.html ISO Schematron] (2006): This version regularizes several features, and provides an XML output format, Schematron Validation Report Language (SVRL).<ref>{{Citation |series=Information technology β Document Schema Definition Languages (DSDL) |title=Part 3: Rule-based validation β Schematron (ISO/IEC 19757-3:2006) |date=2006-06-01 | publisher=ISO/IEC | format=zip | url=http://standards.iso.org/ittf/PubliclyAvailableStandards/c040833_ISO_IEC_19757-3_2006%28E%29.zip|accessdate=2014-06-15}}</ref> It uses the new namespace ''http://purl.oclc.org/dsdl/schematron''. * ISO Schematron (2010) * ISO Schematron (2016): This version added support for XSLT2. * ISO Schematron (2020): This version added support for XSLT3. == Schematron as an ISO Standard == Schematron has been standardized by the ISO as ''Information technology, Document Schema Definition Languages (DSDL)'', Part 3: ''Rule-based validation, Schematron'' (ISO/IEC 19757-3:2020). This standard is currently not listed on the [http://standards.iso.org/ittf/PubliclyAvailableStandards/index.html 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: <syntaxhighlight lang="xml"> http://purl.oclc.org/dsdl/schematron </syntaxhighlight> == Sample rule == Schematron rules can be created using a standard XML editor or [[XForms]] application. The following is a sample schema: <syntaxhighlight lang="xml"> <schema xmlns="http://purl.oclc.org/dsdl/schematron"> <pattern> <title>Date rules</title> <rule context="Contract"> <assert test="ContractDate > current-date()">ContractDate should be in the past because future contracts are not allowed.</assert> </rule> </pattern> </schema> </syntaxhighlight> This rule checks to make sure that the {{mono|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 schemas are suitable for use in [[XML Pipeline]]s, thereby allowing workflow process designers to build and maintain rules using XML manipulation tools. The W3C's [[XProc]] pipelining language, for example, has native support for Schematron schema processing through its "validate-with-schematron" step.<ref name="xproc-w3c-rec">{{citation |mode=cs1 |title=XProc: An XML Pipeline Language |section-url=http://www.w3.org/TR/xproc/#c.validate-with-schematron |section=7.2.5 p:validate-with-schematron |publisher=[[World Wide Web Consortium]] |date=2010-05-11 |access-date=2012-11-12}}</ref> Since Schematron schemas can be transformed into [[XSLT]] stylesheets, these can themselves be used in XML Pipelines which support XSLT transformation. An [[Apache Ant]] task can be used to convert Schematron rules into XSLT files. There exists also native Schematron implementation, like the Java implementation from Innovimax/[[INRIA]], [https://project.inria.fr/quix-tool-suite/quixschematron/ QuiXSchematron], that also do [[Streaming XML|streaming]]. ==See also== * [[XML Schema Language comparison]] - Comparison to other XML Schema languages. * [[Service Modeling Language]] - Service Modeling Language uses Schematron. * [[Document Schema Definition Languages]] == References == {{Reflist}} == External links == * [http://xml.ascc.net/schematron/ Academia Sinica Computing Centre's Schematron Home Page] * [http://www.schematron.info/ A book on Schematron (in German)] * [http://www.data2type.de/en/xml-xslt-xslfo/schematron/ Schematron online tutorial and reference] {{Authority control}} [[Category:Data modeling languages]] [[Category:ISO/IEC standards]] [[Category:XML]] [[Category:XML-based programming languages]] [[Category:XML-based standards]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Authority control
(
edit
)
Template:Citation
(
edit
)
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Mono
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)