What is XSD schema validation in e-invoice processing?
XSD (XML Schema Definition) validation verifies that an XML invoice document conforms to the defined structure and data types of the applicable invoice schema. It checks that all required elements are present, optional elements are in the correct location, data types match (dates, numbers, codes), element nesting is correct, and cardinality constraints are met. XSD validation is the first layer of e-invoice format validation before business rule validation.
How is XSD schema validation performed?
XSD validation using XML processing libraries: (1) Load the XSD schema file for the applicable format version (e.g., Peppol BIS Billing 3.0 XSD); (2) Parse the invoice XML document; (3) Run the XML parser's schema validation function against the loaded XSD; (4) Collect and review validation errors (element not found, wrong data type, cardinality violation); (5) Correct identified errors and re-validate. Most programming languages provide built-in XML validation libraries (Java: javax.xml.validation; Python: lxml; C#: XmlReader with XmlReaderSettings).
Frequently Asked Questions
- What is the difference between XSD validation and Schematron validation?
- XSD validation is structural: it verifies that the XML document is well-formed and conforms to the schema's structural and type definitions. Schematron validation is business rule validation: it applies logical rules such as 'if the supply is exempt, a reason code must be provided' or 'line item sums must equal the header total.' XSD validates structure; Schematron validates business logic. Both layers are required for complete e-invoice validation; XSD typically runs first and Schematron after.
- Where can the official XSD schemas for EU e-invoice formats be obtained?
- Official XSD schemas: Peppol BIS Billing 3.0 from the OpenPeppol GitHub repository; EN 16931 (UBL and CII) from CEN's website and OpenPeppol; Factur-X/ZUGFeRD from the FNFE-MPE website; XRechnung from KoSIT (Koordinierungsstelle für IT-Standards) in Germany; FatturaPA from Agenzia delle Entrate's website; CFDI from SAT Mexico's portal; NF-e from ENCAT (Brazil). Using the officially published schemas rather than third-party copies ensures compliance with the current version.