UBL-SR-43
The rule sets below word this rule differently; each wording is shown with its rule set.
What the rule checks
As the rule set's publisher wrote it. The rule runs on every element the context matches, and fails where the test is false; the validator reports the line of that element.
Scheme identifier shall only be used for invoiced object (document type code with value 130 or 50)
cac:AdditionalDocumentReference
((cbc:DocumentTypeCode='130') or ((local-name(/*) = 'CreditNote') and (cbc:DocumentTypeCode='50')) or (not(cbc:ID/@schemeID) and not(cbc:DocumentTypeCode)))
Checked with EN 16931 Invoice (UBL), EN 16931 Credit Note (UBL), Croatia eRačun Invoice (UBL), Croatia eRačun Credit Note (UBL)
Scheme identifier shall only be used for invoiced object (document type code with value 130)
cac:AdditionalDocumentReference
((cbc:DocumentTypeCode='130') or ((local-name(/*) = 'CreditNote') and (cbc:DocumentTypeCode='50')) or (not(cbc:ID/@scheme) and not(cbc:DocumentTypeCode)))
Checked with Romania RO e-Factura Invoice (UBL), Romania RO e-Factura Credit Note (UBL)