Use unique filenames for embedded documents

Error BR-DE-22 XRechnung

Not all filename attributes of the embeddedDocumentBinaryObject elements are unique

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

At least two ram:AdditionalReferencedDocument elements use the same value in the filename attribute of their ram:AttachmentBinaryObject. The embedded document filenames are therefore not unique.

What the rule means

A unique filename distinguishes embedded documents from one another. The rule requires filenames of referenced documents not to be reused.

Please use a distinct filename for each embedded document

At least two embedded documents in your invoice have the same filename. Change the duplicate names so that each document has its own filename.

What to do
  1. Check the filename attributes of the ram:AttachmentBinaryObject elements.
  2. Compare the filenames in all ram:AdditionalReferencedDocument elements.
  3. Change each duplicate filename.
  4. Generate the invoice again and validate it once more.
What it looks like
✗ Triggers the message
<ram:AdditionalReferencedDocument>
  <ram:AttachmentBinaryObject filename="document.pdf">...</ram:AttachmentBinaryObject>
</ram:AdditionalReferencedDocument>
<ram:AdditionalReferencedDocument>
  <ram:AttachmentBinaryObject filename="document.pdf">...</ram:AttachmentBinaryObject>
</ram:AdditionalReferencedDocument>
✓ Correct
<ram:AdditionalReferencedDocument>
  <ram:AttachmentBinaryObject filename="document-1.pdf">...</ram:AttachmentBinaryObject>
</ram:AdditionalReferencedDocument>
<ram:AdditionalReferencedDocument>
  <ram:AttachmentBinaryObject filename="document-2.pdf">...</ram:AttachmentBinaryObject>
</ram:AdditionalReferencedDocument>
Technical details

The test compares the count of all ram:AdditionalReferencedDocument elements with the count of elements whose filename does not match that of a preceding sibling ram:AdditionalReferencedDocument.

Where the rule applies

The rule applies to all ram:AdditionalReferencedDocument elements and their embedded files in the invoice.

Context (rule/@context)
/rsm:CrossIndustryInvoice
Test expression (assert/@test)
count(//ram:AdditionalReferencedDocument) = count(//ram:AdditionalReferencedDocument[not(./ ram:AttachmentBinaryObject/@filename = preceding-sibling::ram:AdditionalReferencedDocument/ ram:AttachmentBinaryObject/@filename)])