Document type code 50 must occur exactly once

Error FX-SCH-A-000561 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

The additional referenced document does not contain exactly one ram:TypeCode. The element occurs more than once. Because the rule applies to documents with ram:TypeCode 50, in this context it particularly detects duplicate occurrences.

What the rule means

ram:TypeCode identifies the kind of referenced document. Exactly one occurrence prevents multiple document types from being specified for the same referenced document.

Please provide `ram:TypeCode` for the type `50` referenced document exactly once

The additional referenced document contains ram:TypeCode more than once. Exactly one such element is required for this document.

What to do
  1. Locate the additional referenced document with ram:TypeCode 50.
  2. Check whether ram:TypeCode occurs more than once in it.
  3. Remove the extra ram:TypeCode elements so that exactly one remains.
  4. Regenerate the invoice and validate it again.
What it looks like
✗ Triggers the message
<ram:AdditionalReferencedDocument>
  <ram:TypeCode>50</ram:TypeCode>
  <ram:TypeCode>50</ram:TypeCode>
</ram:AdditionalReferencedDocument>
✓ Correct
<ram:AdditionalReferencedDocument>
  <ram:TypeCode>50</ram:TypeCode>
</ram:AdditionalReferencedDocument>
Technical details

The assertion counts the direct ram:TypeCode elements in the current ram:AdditionalReferencedDocument and requires exactly one. The context filter selects documents with ram:TypeCode 50.

Where the rule applies

The rule applies to an additional referenced document with ram:TypeCode 50 within the document-level agreement.

Context (rule/@context)
/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ ram:AdditionalReferencedDocument[ram:TypeCode="50"]
Test expression (assert/@test)
count(ram:TypeCode)=1