XSD+SCH LHDN (Inland Revenue Board of Malaysia) · MyInvois document types 1.0 to 1.3

MyInvois e-Invoice

Malaysian e-invoice for MyInvois (LHDN, UBL)

An e-invoice for LHDN's MyInvois System: invoices, credit, debit and refund notes and their self-billed forms, checked against UBL 2.1 and the MyInvois validations.

About

Malaysia requires e-invoices in phases by annual turnover, starting with businesses above RM100 million on 1 August 2024. An e-invoice is submitted to the MyInvois System of LHDN (HASiL), which validates it and gives it a unique identifier.

Every MyInvois document is a UBL 2.1 Invoice: InvoiceTypeCode 01 is an invoice, 02 a credit note, 03 a debit note, 04 a refund note, and 11 to 14 the same documents self-billed by the buyer. Its listVersionID is the version: 1.1 is signed with the issuer's certificate, 1.0 is not, and 1.2 and 1.3 are their forms for the Voluntary Disclosure programme, until 31 December 2027.

E-invoicing in Malaysia: the rules in short and how to check an invoice →

Good to know

  • Rules run only when the document matches the schema. Documents over 50 MB are checked against the schema only.
  • The rules are xmlvalid's, written from the MyInvois SDK: the fields it marks mandatory, the formats of the core fields, the code tables (classification, MSIC, state, country, currency, tax type, payment mode, unit of measure), currencies and exchange rate, the general TINs, and in a signed version the document digest, the RSA signature and the certificate digest. Ids are LHDN's error codes where it has one (CF, CV, DC, DS, ERR); the mathematical mappings of the SDK are warnings.
  • Not checked: whether a TIN or registration number is registered, the submitter against the certificate, the referenced documents, duplicates and the time of submission, which need the MyInvois System.
  • The schema is UBL 2.1 with one change: the certificate serial number in the signature (X509SerialNumber) is read as an integer of any length, as libxml2 reads integers of up to 24 digits.
  • The examples are by xmlvalid.com with made-up companies and TINs: a signed invoice (version 1.1, with a test certificate), a credit note, a consolidated e-invoice to the general public and a self-billed import from a foreign supplier in USD.

Files

14 files · 2.7 MB · Download all (.zip)
  • maindoc/UBL-Invoice-2.1.xsd main
    58.8 KB View Download
  • common/UBL-CommonAggregateComponents-2.1.xsd
    2.3 MB View Download
  • common/UBL-CommonBasicComponents-2.1.xsd
    214.7 KB View Download
  • common/UBL-CommonExtensionComponents-2.1.xsd
    9.3 KB View Download
  • common/UBL-QualifiedDataTypes-2.1.xsd
    3.5 KB View Download
  • common/UBL-UnqualifiedDataTypes-2.1.xsd
    26.7 KB View Download
  • common/UBL-ExtensionContentDataType-2.1.xsd
    4.2 KB View Download
  • common/CCTS_CCT_SchemaModule-2.1.xsd
    44.2 KB View Download
  • common/UBL-CommonSignatureComponents-2.1.xsd
    5.4 KB View Download
  • common/UBL-SignatureAggregateComponents-2.1.xsd
    7.6 KB View Download
  • common/UBL-SignatureBasicComponents-2.1.xsd
    4.1 KB View Download
  • common/UBL-xmldsig-core-schema-2.1.xsd
    10.9 KB View Download
  • common/UBL-XAdESv132-2.1.xsd
    21.2 KB View Download
  • common/UBL-XAdESv141-2.1.xsd
    1.3 KB View Download

The validator loads all of these with their folder structure, so includes and imports resolve as published.

Business rules

Schematron · run in this order

The rules run after the schema check, only when the document matches the schema, and in your browser like the schema check (with SaxonJS by Saxonica). Each finding names its rule, such as BR-CO-15, and the line it points at; each rule has a page with what it checks.

Example document

invoice.xml · 13.9 KB · passes the schema and the rules

In CI and from code

The same schema by its name, my-myinvois, through the API.

npx @xmlvalid/cli validate "**/*.xml" --schema my-myinvois
- uses: xmlvalid/validate-action@v1
  with:
    files: "**/*.xml"
    schema: my-myinvois
    api-key: ${{ secrets.XMLVALID_API_KEY }}
curl https://xmlvalid.com/api/v1/validations \
  -H "Authorization: Bearer $XMLVALID_API_KEY" \
  -F document=@invoice.xml \
  -F schema=my-myinvois

Free accounts get 100 API validations a month. On Pro, a URL monitor can check a published document against this schema every hour and email you when it breaks. More CI setups