DT-CIUS-PT-020_14.5
The BT-22 when prefixed with '#AMOUNT@ATMPAYMENT-000#' is mandatory an element with the prefix '#REFERENCE@ATMPAYMENT-000#'.
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.
//ubl:Invoice/cbc:Note | //cn:CreditNote/cbc:Note
starts-with(normalize-space(.),$atm20_14) and (every $note in (ancestor::ubl:Invoice/cbc:Note | ancestor::cn:CreditNote/cbc:Note) satisfies (not(starts-with(normalize-space($note),concat('#REFERENCE@ATMPAYMENT-',normalize-space(substring-before(substring-after(.,'#AMOUNT@ATMPAYMENT-'),'#')),'#')))))
Checked with Portugal CIUS-PT Invoice (UBL), Portugal CIUS-PT Credit Note (UBL)