horstoeko / zugferd

ZUGFeRD/XRechnung/Factur-X Library
MIT License
136 stars 24 forks source link

"The XML does not match the requirements for an XML in CII-Syntax" #133

Closed danielmarschall closed 1 week ago

danielmarschall commented 1 week ago

Hello @horstoeko ,

I have migrated from version 8ad5b36d2cb1d69c118c78309d50deb1da7466c7 to the latest version 2381ea9600ba53736c82ef70374e79f00fed7377 in order to support ZUGFeRD 2.3, but unfortunately, ZugferdDocumentPdfBuilderAbstract does not work anymore.

I get the following error message:

The XML does not match the requirements for an XML in CII-Syntax

#0 C:\CORA2012\BAP\bin\phplib_zugferd\src\ZugferdProfileResolver.php(89): horstoeko\zugferd\ZugferdProfileResolver::resolve('<?xml version="...')
#1 C:\CORA2012\BAP\bin\phplib_zugferd\src\ZugferdDocumentPdfMerger.php(121): horstoeko\zugferd\ZugferdProfileResolver::resolveProfileDef('<?xml version="...')
#2 C:\CORA2012\BAP\bin\phplib_zugferd\src\ZugferdDocumentPdfMerger.php(132): horstoeko\zugferd\ZugferdDocumentPdfMerger->getProfileDefinition()
#3 C:\CORA2012\BAP\bin\phplib_zugferd\src\ZugferdDocumentPdfMerger.php(88): horstoeko\zugferd\ZugferdDocumentPdfMerger->getProfileDefinitionParameter('attachmentfilen...')
#4 C:\CORA2012\BAP\bin\phplib_zugferd\src\ZugferdDocumentPdfBuilderAbstract.php(190): horstoeko\zugferd\ZugferdDocumentPdfMerger->getXmlAttachmentFilename()
#5 C:\CORA2012\BAP\bin\phplib_zugferd\src\ZugferdDocumentPdfBuilderAbstract.php(74): horstoeko\zugferd\ZugferdDocumentPdfBuilderAbstract->startCreatePdf()
#6 C:\CORA2012\BAP\bin\cora_zugferd_export.phpy(12) : eval()'d code(1603): horstoeko\zugferd\ZugferdDocumentPdfBuilderAbstract->generateDocument()
#7 C:\CORA2012\BAP\bin\cora_zugferd_export.phpy(12) : eval()'d code(128): cora_zugferd_merge_pdf('c:/cora2012/arc...', 'C:\\CORA2012\\Arc...', 'C:\\CORA2012\\BAP...')
....
#10 {main}

The input XML is identical, so I can exclude the XML generation as faulty. The thing that has changed seems to be the reader/merger.

The used profile:

$document = ZugferdDocumentBuilder::CreateNew(ZugferdProfiles::PROFILE_XRECHNUNG_3);
$document->setDocumentInformation("$belegnr", ZugferdInvoiceType::INVOICE, ...);

The start of the XML, in case you need to know the profile:

<?xml version="1.0" encoding="UTF-8"?>
<rsm:CrossIndustryInvoice xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:a="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:10" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <rsm:ExchangedDocumentContext>
    <ram:BusinessProcessSpecifiedDocumentContextParameter>
      <ram:ID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</ram:ID>
    </ram:BusinessProcessSpecifiedDocumentContextParameter>
    <ram:GuidelineSpecifiedDocumentContextParameter>
      <ram:ID>urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0</ram:ID>
    </ram:GuidelineSpecifiedDocumentContextParameter>
  </rsm:ExchangedDocumentContext>
  <rsm:ExchangedDocument>
    <ram:ID>1629756</ram:ID>
    <ram:TypeCode>380</ram:TypeCode>

The method that caused the problem:

function cora_zugferd_merge_pdf(string $existingXml, string $existingPdf, string $mergeToPdf): void {
    (new ZugferdDocumentPdfMerger($existingXml, $existingPdf))->setAdditionalCreatorTool('...')->generateDocument()->saveDocument($mergeToPdf);
}

This XRechnung validator shows that the XML is okay: https://erechnungsvalidator.service-bw.de/

Thank you for the help!

horstoeko commented 1 week ago

Hi,

I am on vacation. But i cant see no bug. All tests are Green.

Please provide a full ist example

danielmarschall commented 1 week ago

ok; I will try to debug it in order to find the problem. It's not critical, because I still can use the old version

horstoeko commented 1 week ago

Hi @danielmarschall,

Thanks for the fix. However, it should be noted that the update to 2.3 was not the cause... :-)

Kind regards