Skip to content
E-invoicing in Saudi Arabia (FATOORA)

XML canonicalization (C14N 1.1) before hashing

Turning XML text into one standard form before hashing, so the same document gives the same fingerprint on every system.

One document can be written as many texts: attribute order, quote style, namespace declarations, empty elements. Canonicalization (Canonical XML 1.1) maps all of them to one text, and the hash is taken over it.

ZATCA fixes it in the signature block: three XPath transforms removing UBLExtensions, cac:Signature and the QR reference, then the transform http://www.w3.org/2006/12/xml-c14n11. The same method computes the previous invoice hash.

Practical effects for Arabic invoices: text is UTF-8, quotes inside text are not escaped while &, < and > are, and the line whitespace around removed blocks stays in the text.

In JooDax

Built

The programs carry no canonicalizer. Instead they write the document in canonical form from the start (decision D-01: escape &, < and > only and leave quotes, unlike version 1.0), so the written text is the canonical text and the hash is taken from it directly. This relies on every character in the writer staying fixed; 400 golden cases hold it to version 1.0.

crates/jdx-einvoice-sa/src/xml.rs

Related pages

Related concepts

E-invoicing in Saudi Arabia (FATOORA)

Sources

  1. Security Features Implementation Standards to the E-Invoicing resolution dated 2023-05-19 (v1.2) — ZATCA
  2. Electronic Invoice XML Implementation Standard to the E-Invoicing resolution dated 2023-05-19 (v1.2) — ZATCA
  3. E-invoicing Detailed Technical Guidelines (vVersion 2) — ZATCA

Checked on: 4 November 2026. What concerns JooDax is taken from the programs’ own code.