Document type exactly once

Error FX-SCH-A-000020 Factur-X

Element 'ram:TypeCode' must occur exactly 1 times.

Mandatory rule: As long as it is violated, the invoice is invalid and will be rejected by validators.
What is wrong

In ram:ExchangedDocument, ram:TypeCode is either missing or occurs more than once. The element must occur exactly once.

What the rule means

ram:TypeCode specifies the type of invoice document. The document type must be stated unambiguously by exactly one element in the header.

Please provide the document type exactly once

ram:TypeCode is missing from the document header or appears more than once. Having exactly one such element resolves this issue.

What to do
  1. Locate ram:ExchangedDocument in the XML.
  2. Check whether ram:TypeCode is missing or occurs more than once.
  3. Ensure that ram:TypeCode occurs exactly once.
  4. Generate the invoice again and validate it once more.
What it looks like
✗ Triggers the message
<ram:ExchangedDocument/>
✓ Correct
<ram:ExchangedDocument>
  <ram:TypeCode>380</ram:TypeCode>
</ram:ExchangedDocument>
Technical details

The rule uses count(ram:TypeCode)=1 to check that ram:TypeCode occurs exactly once in the context.

Where the rule applies

The rule applies in the invoice header element ram:ExchangedDocument.

Context (rule/@context)
/rsm:CrossIndustryInvoice/rsm:ExchangedDocument
Test expression (assert/@test)
count(ram:TypeCode)=1