0

I am trying to generate Invoice UBL XML file according to this XSD file and this schematron. Once it is generated I am validating it here.

So, according to the schematron, I must have a CustomizationID in my XML file :

<assert id="BR-01" flag="fatal" test="normalize-space(cbc:CustomizationID) != ''">[BR-01]-An Invoice shall have a Specification identifier (BT-24).   </assert>

So I tried to find what kind of value was expected in CustomizationID, so I found here that the default value was urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0, so even thought it might not always be the right value to put in, it should at least be enough to validate the UBL document, am I wrong?

But if I put this value in my XML file and try to validate it, I have an error I don't understand.

Here is my XML file :

<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:ccts="urn:oasis:names:specification:ubl:schema:xsd:CoreComponentParameters-2" xmlns:stat="urn:oasis:names:specification:ubl:schema:xsd:DocumentStatusCode-1.0" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:udt="urn:un:unece:uncefact:data:draft:UnqualifiedDataTypesSchemaModule:2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
    <cbc:ID>A00095678</cbc:ID>
    <cbc:IssueDate>2005-06-21</cbc:IssueDate>
    <cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>
    <cbc:InvoiceTypeCode>SalesInvoice</cbc:InvoiceTypeCode>
    <cac:AccountingSupplierParty>
    </cac:AccountingSupplierParty>
    <cac:AccountingCustomerParty>
    </cac:AccountingCustomerParty>
    <cac:LegalMonetaryTotal>
        <cbc:PayableAmount currencyID="GBP">107.50</cbc:PayableAmount>
    </cac:LegalMonetaryTotal>
    <cac:InvoiceLine>
        <cbc:ID>A</cbc:ID>
        <cbc:LineExtensionAmount currencyID="GBP">100.00</cbc:LineExtensionAmount>
        <cac:Item>
        </cac:Item>
    </cac:InvoiceLine>
</Invoice>

When I try to validate my XML file, I have this error :

cvc-complex-type.2.4.a: Invalid content was found starting with element '{"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":CustomizationID}'. One of '{"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":IssueTime, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":DueDate, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":InvoiceTypeCode, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":Note, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":TaxPointDate, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":DocumentCurrencyCode, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":TaxCurrencyCode, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":PricingCurrencyCode, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":PaymentCurrencyCode, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":PaymentAlternativeCurrencyCode, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":AccountingCostCode, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":AccountingCost, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":LineCountNumeric, "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":BuyerReference, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":InvoicePeriod, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":OrderReference, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":BillingReference, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":DespatchDocumentReference, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":ReceiptDocumentReference, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":StatementDocumentReference, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":OriginatorDocumentReference, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":ContractDocumentReference, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":AdditionalDocumentReference, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":ProjectReference, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":Signature, "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":AccountingSupplierParty}' is expected.

I don't understand the error and how to fix it. First, how is it not a valid content if it is the default value, and second, why is it expecting any of these other fields instead? Any idea?

aprotiere
  • 35
  • 4

1 Answers1

0

Basically it is telling you that is was not expecting CustomizationID at that point, but one if the other elements that it is listing (so they must all be optional except for the last one AccountingSupplierParty), so if you remove CustomizationID, then the next element will be InvoiceTypeCode and it will validate.

Image of Schema

CustomizationID is an optional element <xsd:element minOccurs="0" maxOccurs="1" ref="cbc:CustomizationID">, and the proceeding two elements UBLExtensions and UBLVersionID are also optional, and as you don't have those, CustomizationID should be first, before ID (which is mandatory <xsd:element minOccurs="1" maxOccurs="1" ref="cbc:ID">.

So it should look more like this

<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:ccts="urn:oasis:names:specification:ubl:schema:xsd:CoreComponentParameters-2" xmlns:stat="urn:oasis:names:specification:ubl:schema:xsd:DocumentStatusCode-1.0" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:udt="urn:un:unece:uncefact:data:draft:UnqualifiedDataTypesSchemaModule:2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
    <cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>
    <cbc:ID>A00095678</cbc:ID>
    <cbc:IssueDate>2005-06-21</cbc:IssueDate>
    <cbc:InvoiceTypeCode>SalesInvoice</cbc:InvoiceTypeCode>
    <cac:AccountingSupplierParty>
    </cac:AccountingSupplierParty>
    <cac:AccountingCustomerParty>
    </cac:AccountingCustomerParty>
    <cac:LegalMonetaryTotal>
        <cbc:PayableAmount currencyID="GBP">107.50</cbc:PayableAmount>
    </cac:LegalMonetaryTotal>
    <cac:InvoiceLine>
        <cbc:ID>A</cbc:ID>
        <cbc:LineExtensionAmount currencyID="GBP">100.00</cbc:LineExtensionAmount>
        <cac:Item>
        </cac:Item>
    </cac:InvoiceLine>
</Invoice>

That still fails in Schematron, but not about that field.

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
  • Let me tell you that if i remove CustomizationID, it doesn't validate as i've already tried it [here](https://stackoverflow.com/questions/76863164/how-to-know-what-element-is-mandatory-if-it-has-minioccurs-0-in-ubl/76866189#76866189). And also, the ubl example you linked does not validate either haha – aprotiere Aug 11 '23 at 17:59
  • @aprotiere That is strange as CustomizationdID is optional (MinOccurs = 0) – Dijkgraaf Aug 11 '23 at 21:12
  • @aprotiere I've updated my answer with more details – Dijkgraaf Aug 13 '23 at 00:39
  • It still doesn't validate, I don't know what to do tbh – aprotiere Aug 14 '23 at 14:17
  • 1
    And btw, CustomizationID is optional according to the XSD, but not according to the [schematron](https://github.com/ConnectingEurope/eInvoicing-EN16931/blob/validation-1.3.10/ubl/schematron/preprocessed/EN16931-UBL-validation-preprocessed.sch#L79) – aprotiere Aug 14 '23 at 14:25
  • @aprotiere Even so, you have it in the wrong place, hence you getting the schema validation error. – Dijkgraaf Aug 14 '23 at 20:55
  • Also I notice that the Schemtron validation is expecting release 1.13.10, not sure how that relates to the UBL version – Dijkgraaf Aug 14 '23 at 21:01