Schematron: Support for validation
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 24
- Joined: Thu Jan 07, 2021 10:44 am
Schematron: Support for validation
Post by DanOvergaard »
Hi,
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:choose>
<xsl:when test="$number = -0">
<xsl:value-of select="format-number(0, $format)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="format-number($number, $format)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<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:call-template>
</xsl:variable>
<xsl:variable name="B">
<xsl:call-template name="format-number">
<xsl:with-param name="number" select="
format-number(
(
sum(cbc:LineExtensionAmount) +
sum(../cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount) +
sum(cbc:ChargeTotalAmount) -
sum(cbc:AllowanceTotalAmount) -
sum(cbc:PrepaidAmount) +
sum(cbc:PayableRoundingAmount)
) * -1
,'##.00')"/>
<xsl:with-param name="format" select="'##.00'"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$A = $B">………
/Dan Overgaard
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:choose>
<xsl:when test="$number = -0">
<xsl:value-of select="format-number(0, $format)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="format-number($number, $format)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<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:call-template>
</xsl:variable>
<xsl:variable name="B">
<xsl:call-template name="format-number">
<xsl:with-param name="number" select="
format-number(
(
sum(cbc:LineExtensionAmount) +
sum(../cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount) +
sum(cbc:ChargeTotalAmount) -
sum(cbc:AllowanceTotalAmount) -
sum(cbc:PrepaidAmount) +
sum(cbc:PayableRoundingAmount)
) * -1
,'##.00')"/>
<xsl:with-param name="format" select="'##.00'"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$A = $B">………
/Dan Overgaard
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Schematron: Support for validation
Hello,
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 (xsl-list@lists.mulberrytech.com), There are several XSL experts who can answer there, and also I am registered on the list and can answer.
Best Regards,
Octavian
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 (xsl-list@lists.mulberrytech.com), There are several XSL experts who can answer there, and also I am registered on the list and can answer.
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 24
- Joined: Thu Jan 07, 2021 10:44 am
Re: Schematron: Support for validation
Post 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
I have attached the following files
The files that is used to build the XLS
Please let me know if it’s unclear what I try
Note
I have also send a mail to xsl-list@lists.mulberrytech.com as you suggested
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.
- 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)
OIOUBL_Codelist_Schematron.xml
OIOUBL_Common_Schematron.xml
- OIOUBL_Invoice_Schematron.xsl
- FromNemHandel.xml
INV_LegalMonetaryTotal-PayableRoundingAmount_BZ1710.xml
OIOUBL_Invoice_PayableAmount_0=-0_BZ1465.xml
Fles.zip
Please let me know if it’s unclear what I try
Note
I have also send a mail to xsl-list@lists.mulberrytech.com as you suggested
Fles.zip
You do not have the required permissions to view the files attached to this post.
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Schematron: Support for validation
Hello,
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,
Octavian
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,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 24
- Joined: Thu Jan 07, 2021 10:44 am
Re: Schematron: Support for validation
Post 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
Dan
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
Dan
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Schematron: Support for validation
Hi Dan,
Octavian took a few days off, there's no problem in you coming back when you have some small samples for this.
Regards,
Radu
Octavian took a few days off, there's no problem in you coming back when you have some small samples for this.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service