Skip to content

P1.x: e-SLOG 2.0 XSD output validation#2

Merged
terrxo merged 1 commit into
mainfrom
p1x-eslog-xsd-validation
May 25, 2026
Merged

P1.x: e-SLOG 2.0 XSD output validation#2
terrxo merged 1 commit into
mainfrom
p1x-eslog-xsd-validation

Conversation

@terrxo

@terrxo terrxo commented May 25, 2026

Copy link
Copy Markdown
Contributor

What this adds

The P1.x slice the coordinator flagged: validate the produced e-SLOG XML against the official e-SLOG 2.0 XSD, not just the EN16931 model structurally.

  • validateEslogXml(xml) — validates e-SLOG XML against eSLOG20_INVOIC_v200.xsd (+ its xmldsig-core-schema.xsd import), via xmllint compiled to WebAssembly (xmllint-wasm) — no native bindings, bun-friendly.
  • generateEInvoice(..., { validateOutput: true }) — validate on the way out.
  • New EslogValidationError (422) carrying the XSD issues (line-located).

Conformance result (the point of this slice)

The P1 serializer's output is confirmed valid against the official XSD — and it's regression-locked: tests validate both our output and the official sample invoice from the epos.si package.

Provenance

The XSDs are the official, unmodified schema from the e-SLOG 2.0 (Aug 2020) package published by ePOS/GZS (epos.si/esloge-SLOG-2.0-08-2020-EN.zip), vendored under src/lib/eslog/schema/ with a PROVENANCE.md. Loaded via bun text imports (with { type: "text" }, see src/types.d.ts) so they ship in the package with no build step.

Schematron — why it's not here

The official e-SLOG 2.0 package ships no .sch: the business rules (arithmetic, conditional presence) are prose in the spec PDFs. The XSD enforces structure/types only. Encoding those rules as checks is a future slice (noted in ROADMAP.md); the EN16931 model-level structural validation from P1 already covers the UBL/CII path.

Verification

  • bun test29 pass / 0 fail (+4 over P1: our-output-conformant, official-sample-validates, schema-violation-fails-with-issues, validateOutput path).
  • bunx tsc --noEmit → clean.

Notes

  • Branched off main fb41c05 (merged P1).
  • Adds one dep: xmllint-wasm (pure WASM).
  • The official sample invoice moved to src/test/ as a fixture; the 1.6↔2.0 mapping .xlsx from the package are not vendored.

🤖 Generated with Claude Code

validateEslogXml(xml) validates produced e-SLOG XML against the OFFICIAL
e-SLOG 2.0 XSD (eSLOG20_INVOIC_v200.xsd + its xmldsig-core-schema.xsd import),
vendored from the epos.si Aug-2020 package, via xmllint compiled to WASM
(xmllint-wasm — no native bindings, bun-friendly). XSDs loaded via bun text
imports so they ship in the package with no build step.

Also: generateEInvoice(..., { validateOutput: true }) validates on the way out;
new EslogValidationError (422) carries the XSD issues.

Closes the conformance loop: the P1 serializer's output is confirmed valid
against the official XSD (regression-locked vs both our output and the official
sample invoice). 29/29 tests pass; tsc clean.

No official schematron is published (business rules are spec prose) — that
remains deferred per ROADMAP.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@terrxo terrxo merged commit 6d75516 into main May 25, 2026
2 checks passed
@terrxo terrxo deleted the p1x-eslog-xsd-validation branch May 25, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant