ZUGFeRD / mustangproject

Open Source Java e-Invoicing library, validator and tool (Factur-X/ZUGFeRD, UNCEFACT/CII XRechnung)
http://www.mustangproject.org
Apache License 2.0
168 stars 99 forks source link

Extended Profile Schematron Error #398

Closed c-alpha closed 1 week ago

c-alpha commented 1 week ago

When using validator/src/main/resources/schematron/ZF_221/FACTUR-X_EXTENDED.sch, I get the following error message for line: 27, column: 923 of the Schematron file:

Error in expression (round(.[normalize-space (upper-case 
(ram:TypeCode)) = 'VAT']/xs:decimal (ram:RateApplicablePercent)) = 0 and
(round (xs:decimal (ram:CalculatedAmount)) = 0)) or (round 
(.[normalize-space (upper-case (ram:TypeCode)) = 'VAT']/xs:decimal 
(ram:RateApplicablePercent)) != 0 and ( (abs(xs:decimal 
(ram:CalculatedAmount)) - 1 < round (abs(xs:decimal  (ram:BasisAmount))
* (.[normalize-space (upper-case  (ram:TypeCode)) =
'VAT']/xs:decimal (ram:RateApplicablePercent) div 100) * 10 * 10) div
100 ) and (abs (xs:decimal  (ram:CalculatedAmount)) + 1  >
round(abs(xs:decimal  (ram:BasisAmount)) *
(.[normalize-space (upper-case  (ram:TypeCode)) =
'VAT']/xs:decimal (ram:RateApplicablePercent) div 100) * 10 * 10) div
100 ))) or (not (exists(. [normalize-space 
(upper-case(ram:TypeCode)) ='VAT']/ xs:decimal 
(ram:RateApplicablePercent))) and (round(xs:decimal 
(ram:CalculatedAmount)) = 0)): expected ")", found " ["

Same for the corresponding ZF_220 Schematron file, BTW. Haven't tried any other Schematron files.

Happens with <oXygen/> XML Developer 26.1, build 2024042206.

jstaerk commented 1 week ago

Hi,

what do you mean with "using"? Are you validating something, which input? In the master or in 2.11?

kind regards Jochen

c-alpha commented 1 week ago

Thanks for the swift response!

what do you mean with "using"? Are you validating something, which input?

I downloaded the contents of the ZF_220 directory from the validator/src/main/resources/schematron directory, and configured a Schematron validation scenario for each, the EN 16931 and the EXTENDED ZF profile in XML Developer (which is an XML workbench app), referencing the respective downloaded Schematron file.

In my XML editor app, when validating an invoice under the EN 16931 validation scenario, everything works as expected. Not allowed values from code lists are flagged as "value not allowed", profiled out elements are marked as "not used in this context", etc.

When validating any input file in the XML editor app under the EXTENDED validation scenario, the error message referring to the FACTUR-X_EXTENDED.sch file as shown in my previous message appears.

In the master or in 2.11?

Master branch.

jstaerk commented 1 week ago

Internally we're using ph-schematron in a profile (generateXSLTFromSchematron) to create XSLTs from which we validate.

  1. Why don't you refer to the original sources from the ZUGFeRD Infopaket https://www.ferd-net.de/ZUGFeRD-Download ?
  2. accordingly, please refer to the FeRD for inquiries and issues with the ZUGFeRD Schematron files
  3. Please do note that they do have an open issue (their issue no. 117) which reads "make XSLTs oxygen compatible" which (is on the generated XSLTs and) reads as a workaround to add querybinding=xslt2

replace


<schema xmlns="http://purl.oclc.org/dsdl/schematron"

    schemaVersion="iso">

  <title>Schema for FACTUR-X; 1.0; EN16931-CONFORMANT-EXTENDED</title>

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

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

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

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

with


<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">

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

  <ns prefix="ccts" uri="urn:un:unece:uncefact:documentation:standard:CoreComponentsTechnicalSpecification:2" />

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

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

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

  <ns prefix="xs" uri="http://www.w3.org/2001/XMLSchema" />

good luck with your xml editor.

c-alpha commented 4 days ago

Internally we're using ph-schematron in a profile (generateXSLTFromSchematron) to create XSLTs from which we validate.

  1. Why don't you refer to the original sources from the ZUGFeRD Infopaket https://www.ferd-net.de/ZUGFeRD-Download ?

I do, and the files are identical to the corresponding ones here. So I mistakenly assumed there would be some kind of link. But as it seems you are simply copying them here as external, imported stuff. Apologies for the confusion!

  1. accordingly, please refer to the FeRD for inquiries and issues with the ZUGFeRD Schematron files

Thanks for the pointer; will do.

  1. Please do note that they do have an open issue (their issue no. 117) which reads "make XSLTs oxygen compatible" which (is on the generated XSLTs and) reads as a workaround to add querybinding=xslt2

Is that issue 117 - by any chance - publicly visible anywhere?

replace

<schema xmlns="http://purl.oclc.org/dsdl/schematron" schemaVersion="iso">
 [...]

with

<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
[...]

good luck with your xml editor.

Thanks for the good luck wishes! it turns out that adding @queryBinding="xslt2" is all that it takes. With that, it's workign as expected. Nice fix! 👍