Structure d'une règle
Chaque règle Schematron cible un contexte XPath et émet un assert (erreur) ou report (warning). La combinaison context + test + message permet de comprendre la cause métier.
<sch:pattern id="BR-CO-10">
<sch:rule context="cac:TaxTotal/cbc:TaxAmount">
<sch:assert test=". = sum(../cac:TaxSubtotal/cbc:TaxAmount)">
[BR-CO-10] TaxAmount must equal the sum of subtotals.
</sch:assert>
</sch:rule>
</sch:pattern> Comment investiguer
Reprenez le XPath fourni dans la réponse API et cherchez-le dans votre XML. Identifiez la balise BT correspondante pour remonter au champ métier.
Personnalisation
Vous pouvez ajouter vos propres règles Schematron (branche interne) pour vérifier des contraintes client. Nous stockons vos règles dans un namespace séparé.
- BR custom => namespace fr:facturx:custom
- Chargement via endpoint /api/v1/validate?rules=custom
- Logs dédiés dans la réponse pour distinguer officiel vs custom