ConnectingEurope / eInvoicing-EN16931

Validation artefacts for the European eInvoicing standard EN 16931
Other
134 stars 53 forks source link

XML prefixes #61

Closed CEFSUPPORT closed 5 years ago

CEFSUPPORT commented 6 years ago

Hello, We got the following request:

"UBL test was OK, but we have some problems with CEFACT validation. When we uploaded e-invoice which uses xml prefixes, everything was OK (attachment CEFACT_OK.xml). This was the input parameter (invoice) in our conversion process. When we uploaded e-invoice which uses default namespaces, we received ERRORS (attachment CEFACT_ERROR.xml – error report report_error.pdf). This was the output (invoice) from our conversion process. According to XML standard, those two files are both valid to XSD schema and are equal. Only the sintax is different. Could you please help as on our problem? Is there a bug, or maybe we missed something?"

Our expert's comment:

Both files that they have tested are technically correct when it comes to the use of namespaces. It is functionally equivalent to use default namespace or prefix as long as the correct namespace is referenced (and it is in their case).

It seems to me as if the CII schematron rules are incorrect. They incorrectly assume that the prefix “ram:” is always used. The error comes from the statement below (highlighted in red, italic, bold, underlined). There may be many similar errors (they have found a handful).

not(ram:Name) or (name()='ram:AdditionalReferencedDocument' and ram:TypeCode='916')

So a good catch from the Slovenians. Obviously, no one has tested CII with other prefixes than the ones from the TC434 sample file…

Btw, to fix the rule, the following part

name()='ram:AdditionalReferencedDocument'

should be changed to

local-name()='AdditionalReferencedDocument'

Could you please check for the possible fixing?

Thanks, CEFSUPPORT

phax commented 6 years ago

Hi. Can you add the attachments as well please. Thanks

CEFSUPPORT commented 6 years ago

Hi, I'm uploading a fragment of the "good" and the "bad" eInvoice instance and the error report.

CEFACT_OK.txt CEFACT_ERROR.txt report_error.pdf

phax commented 6 years ago

I have created an example file with a different namespace prefix than "ram" and it works without problems. Maybe it is an error in the Midran validator? The fixed "ram" prefix is used, because it is part of the CII Schematron rules (<ns...>). hth

MartinForsberg-Ecru commented 6 years ago

No, the name()='ram:AdditionalReferencedDocument' statement string-compares the name (including prefix). I didn't spot this using validex, just XML Spy Xpath evaluator.

phax commented 6 years ago

But the prefix for Schematron inside the SCH:

  <ns prefix="ram"
    uri="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"/>
MartinForsberg-Ecru commented 6 years ago

Yes, schematron/XSLT is aware of namespaces as the are declared. That's why a string comparison against a specific prefix ends up in unexpected results. And the name() function returns the element name including the prefix as a string. The rule then incorrectly assumes that the prefix always is ram:.

/Martin Forsberg


From: Philip Helger notifications@github.com Sent: Tuesday, April 10, 2018 1:24:04 PM To: CenPC434/validation Cc: Martin Forsberg; Comment Subject: Re: [CenPC434/validation] XML prefixes (#61)

But the prefix for Schematron inside the SCH:

<ns prefix="ram" uri="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"/>

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/CenPC434/validation/issues/61#issuecomment-380064816, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Ad1DbPrgobYJEmSn9Ef-heawEnexE2qCks5tnJZUgaJpZM4St4pg.

kosek commented 6 years ago

The easiest fix to wrong expressions like name()='ram:AdditionalReferencedDocument' is to use self::ram:AdditionalReferencedDocument The nature of expression is to check name of the current element and this can be done easily by using self:: node.