UBL Invoice validation: Cannot find the declaration of element 'ubl:Invoice'
I have a simple Invoice xml:
<?xml version="1.0" encoding="UTF-8"?>
<ubl:Invoice xmlns:ubl="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0</cbc:CustomizationID>
<cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>
<cbc:ID>RE-2024-03</cbc:ID>
<cbc:IssueDate>2024-02-27</cbc:IssueDate>
<cbc:DueDate>2024-03-28</cbc:DueDate>
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
<cbc:BuyerReference>992-90009-96</cbc:BuyerReference>
<cac:AccountingSupplierParty>
<cac:Party>
<cbc:EndpointID schemeID="9918">DE16520503531004885412</cbc:EndpointID>
<cac:PostalAddress>
<cbc:StreetName>Teichstr. 15</cbc:StreetName>
<cbc:CityName>Berlin</cbc:CityName>
<cbc:PostalZone>10232</cbc:PostalZone>
<cac:Country>
<cbc:IdentificationCode>DE</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID>279247134</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>FC</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:PartyLegalEntity>
<cbc:RegistrationName>PC Service GmbH</cbc:RegistrationName>
<cbc:CompanyID>279247134</cbc:CompanyID>
</cac:PartyLegalEntity>
<cac:Contact>
<cbc:Name>Max Siebert</cbc:Name>
<cbc:Telephone>0312424323</cbc:Telephone>
<cbc:ElectronicMail>max.siebert@pc-service-berlin.de</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
</cac:AccountingSupplierParty>
<cac:AccountingCustomerParty>
<cac:Party>
<cbc:EndpointID schemeID="9930">DE279247134</cbc:EndpointID>
<cac:PostalAddress>
<cbc:StreetName>Bergstr. 25</cbc:StreetName>
<cbc:CityName>Frankfurt</cbc:CityName>
<cbc:PostalZone>54632</cbc:PostalZone>
<cbc:CountrySubentity>Hessen</cbc:CountrySubentity>
<cac:Country>
<cbc:IdentificationCode>DE</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyLegalEntity>
<cbc:RegistrationName>DB Service GmbH</cbc:RegistrationName>
<cbc:CompanyID>DE279247134</cbc:CompanyID>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingCustomerParty>
<cac:Delivery>
<cbc:ActualDeliveryDate>2024-02-24</cbc:ActualDeliveryDate>
</cac:Delivery>
<cac:PaymentMeans>
<cbc:PaymentMeansCode>42</cbc:PaymentMeansCode>
<cac:PayeeFinancialAccount>
<cbc:ID>DE13520503531004885466</cbc:ID>
<cbc:Name>Viktor Settel</cbc:Name>
<cac:FinancialInstitutionBranch>
<cbc:ID>HELADEF1KAS</cbc:ID>
</cac:FinancialInstitutionBranch>
</cac:PayeeFinancialAccount>
</cac:PaymentMeans>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="EUR">204.06</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="EUR">1074.00</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="EUR">204.06</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>19.00</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="EUR">1074.00</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="EUR">1074.00</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="EUR">1278.06</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount currencyID="EUR">0.00</cbc:AllowanceTotalAmount>
<cbc:ChargeTotalAmount currencyID="EUR">0.00</cbc:ChargeTotalAmount>
<cbc:PrepaidAmount currencyID="EUR">0.00</cbc:PrepaidAmount>
<cbc:PayableRoundingAmount currencyID="EUR">0.00</cbc:PayableRoundingAmount>
<cbc:PayableAmount currencyID="EUR">1278.06</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<cac:InvoiceLine>
<cbc:ID>1</cbc:ID>
<cbc:InvoicedQuantity unitCode="C62">2.000000</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="EUR">934.00</cbc:LineExtensionAmount>
<cac:Item>
<cbc:Name>PC Fujitsu TX-23</cbc:Name>
<cac:ClassifiedTaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>19.00</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="EUR">467.000000</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine>
<cac:InvoiceLine>
<cbc:ID>2</cbc:ID>
<cbc:InvoicedQuantity unitCode="C62">2.000000</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="EUR">140.00</cbc:LineExtensionAmount>
<cac:Item>
<cbc:Name>PC Installation</cbc:Name>
<cac:ClassifiedTaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>19.00</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="EUR">70.000000</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine>
</ubl:Invoice>
And the following .xsd to validate it:
https://github.com/itplr-kosit/xrechnung-visualization/blob/master/src/xsd/xrechnung-semantic-model.xsd
Each time I try to validate the xml, it tells me:
11:76 cvc-elt.1.a: Cannot find the declaration of element 'ubl:Invoice'.
But if you look at the .xml, ubl:Invoice
is present.
The .xml has to be in the format provided by xrechnung-semantic-model.xsd
, in order for it to be processed by xr-pdf.xsl
.
Answers
The error message you're encountering, cvc-elt.1.a: Cannot find the declaration of element 'ubl:Invoice'
, indicates that the XML validator is unable to find the declaration of the 'ubl:Invoice' element. This usually happens when the XML document is not associated with the correct XML schema or namespace.
To resolve this issue, ensure the following:
-
Namespace Declaration: Make sure that the namespace prefix (
ubl
) used in the XML document is correctly declared and associated with the correct namespace URI in the XML schema. -
Schema Location: Ensure that the XML document references the correct XML schema location using the
xsi:schemaLocation
attribute. This attribute specifies the location of the XML schema that defines the elements and attributes used in the XML document. -
Correct Namespace URI: Verify that the namespace URI declared in the XML document matches the namespace URI defined in the XML schema.
-
XML Schema Import: If the XML schema imports other schemas or namespaces, ensure that these imports are correctly specified and that all referenced schemas are accessible.
Here's an example of how you can declare the namespace and schema location in your XML document:
<?xml version="1.0" encoding="UTF-8"?>
<ubl:Invoice xmlns:ubl="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 xrechnung-semantic-model.xsd">
<!-- Your XML content here -->
</ubl:Invoice>
Make sure to replace xrechnung-semantic-model.xsd
with the actual path or URL to the XML schema file.
By ensuring that the XML document is correctly associated with the XML schema and namespace, you should be able to resolve the validation error. If you continue to encounter issues, double-check the namespace declarations, schema locations, and ensure that the XML document structure aligns with the schema definition.