-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Hi,
I am busy with a peppol/ubl implementation and am using your command line tool to verify my generated xml against the schematron. It works fine in most cases but for one file I get a failure caused by a rounding error. The rule that fails checks if some sum is the same as a value stated elsewhere in the file. See: https://docs.peppol.eu/poacc/billing/3.0/rules/ubl-tc434/BR-AE-08/
The schematron states that the values are xs:decimal, but it seems that native javascript is being used. If I do 24.63 + 62.16 in the console of my browser I also get a rounding error: 86.78999999999999.
I created a sample that does the same calculation.
Sample xml:
<?xml version="1.0"?>
<Invoice>
<Total>
86.79
</Total>
<Lines>
<Line>
<SubTotal>
24.63
</SubTotal>
</Line>
<Line>
<SubTotal>
62.16
</SubTotal>
</Line>
</Lines>
</Invoice>Sample schematron:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<ns prefix="xs" uri="http://www.w3.org/2001/XMLSchema"/>
<pattern id="ubl-model">
<rule context="/*">
<assert test="(xs:decimal(Total) = sum(Lines/Line/xs:decimal(SubTotal)))">
<value-of select="xs:decimal(Total)" /> is not the same as <value-of select="sum(Lines/Line/xs:decimal(SubTotal))" />
</assert>
</rule>
</pattern>
</schema>The failed assertion of my sample says:
asrt ✘ 86.79 is not the same as 86.78999999999999
Regards,
Gert Jan