Optional Schematron validation against the EN 16931 business rules.
The EN 16931 Schematron compiles to XSLT 2.0, which the BEAM cannot run. Like
the Python akretion/factur-x library, we delegate to a Saxon server over
HTTP (req — declared optional so non-validating callers don't pull an HTTP
client). The compiled schematron XSLT ships in priv/schematron/.
Run a Saxon server (e.g. ghcr.io/willemvlh/saxon-server, port 5000) and
point :endpoint at its /transform route. The transform is sent the XML and
the XSLT as a multipart/form-data body and returns an SVRL report, which we
interpret into failed-assert / successful-report violations.
Privacy: a public Saxon endpoint means sending real invoice data to a third party. Self-host the Saxon server in production.
{:ok, :valid} = Facturx.validate(xml, profile: :en16931,
endpoint: "http://localhost:5000/transform")Only the :en16931 schematron ships today; other profiles return
{:error, {:schematron_not_bundled, profile}}.
Summary
Types
A schematron violation.
Functions
Validate xml against the EN 16931 Schematron via a Saxon endpoint.
Types
Functions
@spec validate( binary(), keyword() ) :: {:ok, :valid} | {:error, {:invalid, [violation()]}} | {:error, term()}
Validate xml against the EN 16931 Schematron via a Saxon endpoint.
Options:
:endpoint— Saxon/transformURL (defaults to the app envconfig :facturx, Facturx.Validate, endpoint: ..., then"http://localhost:5000/transform"):profile— schematron level (defaults to the profile detected in the XML):codedb_url— override the code-list DB URL the XSLT resolves:receive_timeout— HTTP receive timeout (ms), default 20_000