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.