This document describes rules common to all EHF (Norwegian: Elektronisk Handelsformat; EHF) formats.

Reporting bugs
Please use Github Issues to report bugs and lack of content when discovered. Users currently not registered on Github may create an account for free.

Introduction

EHC Common is a set of common rules applying to all document types part of EHF in Post-Award.

This document functions as a reference for each of the rules.

1. Changelog

1.1. Version 1.x

Version 1.0.5 (2019-02-27)

Issue Description Type

#274

Fixing calculation error in rule EHF-COMMON-R050 for GLN identifiers with 0 (zero) as check digit.

Validator

Validation rules expected to be updated to trigger error in next release: EHF-COMMON-R005

Version 1.0.4 (2018-11-15)

Issue Description Type

-

Adding rule EHF-COMMON-R005.

Validator

Validation rules expected to be updated to trigger error in next release: EHF-COMMON-R005

Version 1.0.3 (2018-09-12)

Issue Description Type

#262

Change rule EHF-COMMON-R050 to trigger with error.

Validator

Version 1.0.2 (2018-02-20)

Issue Description Type

#245

Adding tax categories "AE" and "G".

Validator

#262

Adding rule to trigger upon multiple Note elements.

Validator

Validation rules expected to be updated to trigger error in next release: EHF-COMMON-R050

Version 1.0.1 (2017-11-15)

Issue Description Type

#238

Using EHF Common for EHF Invoice and Credit Note.

Validator

#245

Adding information related to new tax categories valid as of next release.

Guide

Version 1.0.0 (2017-09-14)

Issue Description Type

#222

Initial use of validation rules.

Validator

#222

Initial guide.

Guide

2. Rules

2.1. R00X - Document in general

2.1.1. EHF-COMMON-R001

Table 1. Description

Context

cbc:* (Pattern 1)

Rule

. != ''

Message

Document MUST not contain empty elements.

Type

Error

Since

1.0.0

Elements in UBL used by EHF may be divided into two groups; those containing elements (cac) and those containing values (cbc). This rule verifies there are no elements for values being empty.

Elements without content are expected to be removed as long as they are optional. Mandatory elements must contain a valid value.

Examples expected to be invalid.
<cbc:ID></cbc:ID>
<cbc:ID/>
Example expected to be valid.
<cbc:ID>3150jd</cbc:ID>
Table 2. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Active

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Active

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.1.2. EHF-COMMON-R002

Table 3. Description

Context

cac:* (Pattern 1)

Rule

count(*) != 0

Message

Document MUST not contain empty elements.

Type

Error

Since

1.0.0

Elements in UBL used by EHF may be divided into two groups; those containing elements (cac) and those containing values (cbc). This rule verifies there are no elements for child elements being empty.

Elements without child elements are expected to be removed as long as they are optional. Mandatory elements must contain child elements according to the specification.

Example expected to be invalid.
<cac:ExternalReference>
</cac:ExternalReference>
Example expected to be valid.
<cac:ExternalReference>
  <cbc:URI>https://vefa.difi.no/</cbc:URI>
</cac:ExternalReference>
Table 4. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Active

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Active

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.1.3. EHF-COMMON-R003

Table 5. Description

Context

/* (Pattern 2)

Rule

not(@*:schemaLocation)

Message

Document SHOULD not contain schema location.

Type

Warning

Since

1.0.0

Example expected to be invalid.
<ApplicationResponse
  xmlns="urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" (1)
  xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
  xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
  xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2 UBL-ApplicationResponse-2.1.xsd"> (2)
1 Namespace for XML Schema Instance (XSI).
2 Pointer towards location of XSD.
Example expected to be valid.
<ApplicationResponse
  xmlns="urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2"
  xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
  xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
Table 6. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Active

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Active

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.1.4. EHF-COMMON-R004

Table 7. Description

Context

/* (Pattern 2)

Rule

cbc:UBLVersionID

Message

Document MUST have a syntax identifier.

Type

Error

Since

1.0.0

All UBL 2.x document types contains a UBLVersionID element as first element to help parsers to know which version of UBL was used by the document creater. This is important as newer minor versions of UBL 2.x may contain new elements, meaning a document instance created using UBL 2.1 may not be parseable using the UBL 2.0 schema.

We have made UBLVersionID mandatory as we want to be a good citizen in the UBL community.

Examples expected to be invalid.
<Catalogue ...>
  <!-- Content not containing element "UBLVersionID" -->
</Catalogue>
Example expected to be valid.
<Catalogue ...>
  <cbc:UBLVersionID>2.1</cbc:UBLVersionID>
  <!-- Content -->
</Catalogue>
Table 8. Valid values of UBLVersionID.
EHF document type UBL version

EHF Catalogue 1.x

2.1

EHF Catalogue Response 1.x

2.1

EHF Credit Note 2.x

2.1

EHF Despatch Advice 1.x

2.1

EHF Invoice 2.x

2.1

EHF Order 1.x

2.1

EHF Order Response 1.x

2.1

EHF Reminder 1.x

2.0

Table 9. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Active

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Active

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.1.5. EHF-COMMON-R005

Table 10. Description

Context

cbc:* (Pattern 1)

Rule

every $attr in @* satisfies normalize-space($attr) != ''

Message

Attributes MUST contain value.

Type

Warning

Since

1.0.4

Table 11. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Active

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Active

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.2. R01X - Validation of Norwegian organization numbers

2.2.1. EHF-COMMON-R010

Table 12. Description

Context

cbc:EndpointID[@schemeID = 'NO:ORGNR'] (Pattern 2)

Rule

matches(., '^[0-9]{9}$') and u:mod11(.)

Message

MUST be a valid Norwegian organization number. Only numerical value allowed

Type

Error

Since

1.0.0

Example expected to be invalid.
<cbc:EndpointID schemeID="NO:ORGNR">999 999 999</cbc:EndpointID>
Example expected to be valid.
<cbc:EndpointID schemeID="NO:ORGNR">810418052</cbc:EndpointID>
Table 13. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Active

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Active

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.2.2. EHF-COMMON-R011

Table 14. Description

Context

cac:PartyIdentification/cbc:ID[@schemeID = 'NO:ORGNR'] (Pattern 2)

Rule

matches(., '^[0-9]{9}$') and u:mod11(.)

Message

When scheme is NO:ORGNR, a valid Norwegian organization number must be used. Only numerical value allowed

Type

Error

Since

1.0.0

Example expected to be invalid.
<cac:PartyIdentification>
  <cbc:ID schemeID="NO:ORGNR">999 999 999</cbc:ID>
</cac:PartyIdentification>
Example expected to be valid.
<cac:PartyIdentification>
  <cbc:ID schemeID="NO:ORGNR">810418052</cbc:ID>
</cac:PartyIdentification>
Table 15. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Active

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Active

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.2.3. EHF-COMMON-R012

Table 16. Description

Context

cbc:CompanyID[@schemeID = 'NO:VAT'] | cac:PartyTaxScheme/cbc:CompanyID[not(@schemeID)] (Pattern 2)

Rule

matches(., '^[0-9]{9}MVA$') and u:mod11(substring(., 1, 9))

Message

A VAT number MUST be valid Norwegian organization number (nine numbers) followed by the letters MVA.

Type

Error

Since

1.0.0

Example expected to be invalid.
<cac:PartyTaxScheme>
  <cbc:CompanyID schemeID="NO:VAT">999 999 999 MVA</cbc:CompanyID>
</cac:PartyTaxScheme>
Example expected to be valid.
<cac:PartyTaxScheme>
  <cbc:CompanyID schemeID="NO:VAT">810418052MVA</cbc:CompanyID>
</cac:PartyTaxScheme>
Table 17. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Ignored

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Ignored

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Ignored

2.2.4. EHF-COMMON-R013

Table 18. Description

Context

cbc:CompanyID[@schemeID = 'NO:ORGNR'] | cac:PartyLegalEntity/cbc:CompanyID[not(@schemeID)] (Pattern 2)

Rule

matches(., '^[0-9]{9}$') and u:mod11(.)

Message

When scheme is NO:ORGNR, a valid Norwegian organization number must be used. Only numerical value allowed

Type

Error

Since

1.0.0

Example expected to be invalid.
<cac:PartyLegalEntity>
  <cbc:CompanyID schemeID="NO:ORGNR">999 999 999</cbc:CompanyID>
</cac:PartyLegalEntity>
Example expected to be valid.
<cac:PartyLegalEntity>
  <cbc:CompanyID schemeID="NO:VAT">810418052</cbc:CompanyID>
</cac:PartyLegalEntity>
Table 19. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Ignored

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Ignored

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Ignored

2.2.5. EHF-COMMON-R014

Table 20. Description

Context

cbc:EndpointID (Pattern 2)

Rule

false()

Message

An endpoint identifier scheme MUST have the value 'NO:ORGNR'.

Type

Error

Since

1.0.0

Example expected to be invalid.
<cbc:EndpointID>810418052</cbc:EndpointID>
Example expected to be valid.
<cbc:EndpointID schemeID="NO:ORGNR">810418052</cbc:EndpointID>
Table 21. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Active

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Active

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.3. R02X - Validation of tax

2.3.1. EHF-COMMON-R020

Table 22. Description

Context

cac:*[ends-with(name(), 'TaxCategory')]/cbc:ID (Pattern 2)

Rule

some $code in tokenize('AA E H K R S Z', '\s') satisfies $code = normalize-space(.)

Message

Tax categories MUST be one of the follwoing codes: AA E H K R S Z

Type

Error

Since

1.0.0

Examples expected to be invalid.
<cac:TaxCategory>
  <cbc:ID>A</cbc:ID>
</cac:TaxCategory>
Example expected to be valid.
<cac:TaxCategory>
  <cbc:ID>AA</cbc:ID>
</cac:TaxCategory>
Table 23. Valid VAT categories and rates
VAT category Description Rate as of January 1, 2016

S

Output VAT, regular rate

25%

H

Output VAT, reduced rate, middle

15%

R

Output VAT, reduced rate, raw fish

11,11%

AA

Output VAT, reduced rate, low

10%

E

VAT excempt

0%

Z

VAT excempt (Goods and services not included in the VAT regulations)

0%

K

Emission allowances for private or public businesses – buyer calculates VAT

0%

AE

Reversed VAT

0%

G

Export of goods and services

0%

Table 24. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Ignored

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Ignored

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.4. R03X - Formating validation

2.4.1. EHF-COMMON-R030

Table 25. Description

Context

cbc:*[ends-with(name(), 'Date')] (Pattern 2)

Rule

(string(.) castable as xs:date) and (string-length(.) = 10)

Message

A date must be formatted YYYY-MM-DD.

Type

Error

Since

1.0.0

Example expected to be invalid.
<cbc:IssueDate>2017-01-01Z</cbc:IssueDate>
Example expected to be valid.
<cbc:IssueDate>2017-01-01</cbc:IssueDate>
Table 26. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Active

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Active

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.5. R04X - Validation of other identifiers

2.5.1. EHF-COMMON-R040

Table 27. Description

Context

cbc:ID[@schemeID = 'GLN'] (Pattern 2)

Rule

matches(., '^[0-9]+$') and u:gln(.)

Message

Invalid GLN number provided.

Type

Warning

Since

1.0.0

Example expected to be invalid.
<cac:PartyIdentification>
  <cbc:ID schemeID="GLN">6291041500212</cbc:ID>
</cac:PartyIdentification>
Example expected to be valid.
<cac:PartyIdentification>
  <cbc:ID schemeID="GLN">6291041500213</cbc:ID>
</cac:PartyIdentification>
Table 28. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Ignored

EHF Catalogue Response 1.x

Ignored

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Active

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.6. R05X - Validation of text elements

2.6.1. EHF-COMMON-R050

Table 29. Description

Context

cbc:Note[2] (Pattern 2)

Rule

false()

Message

Only one note element is allowed.

Type

Error

Since

1.0.2

Table 30. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Active

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Active

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Active

2.7. R1XX - Code lists

2.7.1. EHF-COMMON-R100

Table 31. Description

Context

cbc:EmbeddedDocumentBinaryObject[@mimeCode] (Pattern 2)

Rule

some $code in tokenize('application/pdf image/gif image/tiff image/jpeg image/png text/plain', '\s') satisfies $code = normalize-space(@mimeCode)

Message

Attachment is not a recommended MIMEType.

Type

Warning

Since

1.0.0

Table 32. Document type matrix
Document type Status Comment

EHF Catalogue 1.x

Active

EHF Catalogue Response 1.x

Ignored

EHF Credit Note 2.x

Active

EHF Despatch Advice 1.x

Ignored

EHF Invoice 2.x

Active

EHF Order 1.x

Active

EHF Order Response 1.x

Ignored

3. Appendix

Appendix A: Schematron

Validation files based on Schematron may be found in our Github repoistory. Release "2021-02-15" is used for the current version of resources and branch "master" is for development and review.

Difi provides validation artifacts as Schematron and not as XSLT as of release 2016-11-15.