Page 1 of 1

Schematron: Support for validation

Posted: Wed Jun 09, 2021 3:58 pm
by DanOvergaard

I am not 100% sure that this is the right forum but I hope to find help

My problem is that an addition of multiple totals end up in a very tiny number (-1.8189894035458565E-12) rather than 0 (In XSLT 1.0 every number is treated as double and when adding decimal, numbers rounding occurs). I then format the result ##.00 to ensure 0, but MSXML and Saxon handle format-number different where Saxon is that format-numb keeps the sign even if the result is 0, so I end up with matching 0 = -0 and my test fail.

I have built the XLS “Function” below that will handled the problem but I can’t work out how to build a Schematron “function” that will be do the same when transformed into XLS. Can anybody help ?

<xsl:template name="format-number">
<xsl:param name="number"/>
<xsl:param name="format"/>
<xsl:when test="$number = -0">
<xsl:value-of select="format-number(0, $format)"/>
<xsl:value-of select="format-number($number, $format)"/>
<xsl:variable name="A">
<xsl:call-template name="format-number">
<xsl:with-param name="number" select="sum(cbc:PayableAmount)"/>
<xsl:with-param name="format" select="'##.00'"/>

<xsl:variable name="B">
<xsl:call-template name="format-number">
<xsl:with-param name="number" select="
sum(cbc:LineExtensionAmount) +
sum(../cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount) +
sum(cbc:ChargeTotalAmount) -
sum(cbc:AllowanceTotalAmount) -
sum(cbc:PrepaidAmount) +
) * -1
<xsl:with-param name="format" select="'##.00'"/>

<xsl:when test="$A = $B">………

/Dan Overgaard

Re: Schematron: Support for validation

Posted: Fri Jun 11, 2021 10:07 am
by tavy

I can try to help you if you provide more information in order to reproduce the problem: What version of Oxygen do you use? What version of Saxon do you use for transformation? Maybe you can send also a sample XML file.

I recommend you to write on the XSL List (, There are several XSL experts who can answer there, and also I am registered on the list and can answer.

Best Regards,

Re: Schematron: Support for validation

Posted: Mon Jun 14, 2021 11:50 am
by DanOvergaard
Hi Octavian,

Thanks for your feedback 😊

My challenge are that I don’t know how to solve the problem in the Schematron file – The file that is used to build the XSL-fil for validating. I need to find a logic that handle
  • The problem with SAXON vs .Net (not version specific), but that .Net see “-0 = 0” as TRUE where SASON see it a FALSE
    The problem with tiny numbers are - in XSLT 1.0 – is treated as double and when adding decimal, numbers rounding occurs.
So I need to match two variables where one of them are a sum of multiple values . The sum of the multiple values end up as a very tiny number (eg.: -1.8189894035458565E-12) that are negative. So I need to:
  • Ensure that the “sum” of the two valuables are formatted to ##.00
    Ensure the that the two values both have the same sign

I have attached the following files
The files that is used to build the XLS
  • OIOUBL_Invoice_Schematron.xml: The schematron file that build the XSL file below (The logic is found on line 1292)
The XSL file that is used to validate the
  • OIOUBL_Invoice_Schematron.xsl
Test files
  • FromNemHandel.xml
(185.99 KiB) Downloaded 12 times

Please let me know if it’s unclear what I try 😊

I have also send a mail to as you suggested
(185.99 KiB) Downloaded 11 times

Re: Schematron: Support for validation

Posted: Fri Jun 18, 2021 4:21 pm
by tavy

Unfortunately, it is hard for me to understand the examples. I tried to make some simple examples but they seem work in Oxygen. If you could create some simple examples that can be run in Oxygen XML Editor , and reproduce the issue you reported, I will try to debug them.

Best Regards,

Re: Schematron: Support for validation

Posted: Fri Jul 02, 2021 3:41 pm
by DanOvergaard
Hi Octavian,

Sorry for my late reply, but I have been assigned to other more pressing issues :-)

I will come back with some simplified examples, but not until late August.

So shall I close the case and create a new at that time or keep this open ?

Best regards

Re: Schematron: Support for validation

Posted: Mon Jul 05, 2021 6:53 am
by Radu
Hi Dan,

Octavian took a few days off, there's no problem in you coming back when you have some small samples for this.