Glossary Term

Schematron

Schematron is an XML-based validation language that checks business rules in e-invoices using XPath expressions, producing specific error codes when conditions fail.

Quick Facts

Type
Validation Language
Used by
KoSIT, Peppol, EN 16931
Standard
ISO/IEC 19757-3
Expression language
XPath

Definition

What is Schematron?

Schematron is a rule-based validation language for XML documents. In e-invoicing, it's the technology that checks whether an invoice follows the business rules defined by EN 16931, Peppol BIS, XRechnung, and other specifications.

Unlike XML Schema (XSD), which validates structure (is this field present? is it the right type?), Schematron validates business logic (does the tax calculation add up? is the required buyer reference present?).

How Schematron Works

Schematron rules consist of:

1. Context — which XML element to check
2. Assert/Report — an XPath expression that must be true/false
3. Error code — the identifier returned when the rule fails
4. Message — human-readable description of the error

Example Rule (simplified)


flag="fatal"
id="BR-26">
Invoice line net amount must not be negative.


Who Uses Schematron for E-Invoicing?

Validation Artifact Publisher Error Prefix
---------------------------------------------
EN 16931 rules CEN TC 434 BR-, BR-CO-
Peppol BIS 3.0 OpenPeppol PEPPOL-EN16931-*
XRechnung KoSIT BR-DE-*
SI-UBL Logius NL-*

Validation Tools

  • KoSIT Validator — Germany's reference validator, uses Schematron internally

  • Peppol Validation Artifacts — published on GitHub by OpenPeppol

  • Invoice Navigator — applies Schematron rules as part of its validation engine
  • Common Concepts

  • Fatal vs Warning — fatal errors block acceptance, warnings are informational

  • XPath — the expression language used inside Schematron rules

  • XSLT compilation — Schematron files are compiled to XSLT for faster execution