Skip to main content
XMLDir

Search 309 pages — tools, formats, elements, namespaces, directory, comparisons, XPath, datatypes, glossary, parse errors, schema errors, use cases, blog and product.

Schemas and validity

Schematron

A rule-based schema language that asserts XPath conditions about a document, rather than describing its grammar.

Schematron answers the questions a grammar cannot: this total must equal the sum of the lines, this end date must not precede the start date, this element is required only when that attribute is present. Rules are XPath expressions with human-readable messages, which makes its output the most actionable of any schema language.

It is usually layered on top of XSD rather than replacing it — the grammar checks the shape, Schematron checks the relationships. It is also the one schema language this site cannot run: the WebAssembly build of libxml2 reports an internal error for valid and invalid documents alike, so publishing a Schematron validator would mean publishing a coin flip.

Defined in
ISO/IEC 19757-3
Category
Schemas and validity
Also written
ISO Schematron, .sch

Why there is no demo

Nothing here to execute

Our engine cannot run Schematron. The WebAssembly build of libxml2 returns the same internal error for a document that satisfies the rules and one that violates them, so any demonstration here would be asserting a result nothing produced. The /about page says the same thing about why the validator is missing.

What catches people out

  • Schematron rules are XPath, so everything true of XPath is true of them — including that an unprefixed name in a namespaced document matches nothing.
  • It constrains relationships, not structure. Use it alongside a grammar rather than instead of one.
  • Most implementations compile Schematron to XSLT and run that, which means your XPath version is whatever the XSLT processor supports.

Get started

Bring order to the XML your team can't afford to ignore.

Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.