XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1177)
- Stylus Studio Technical Forum (14546)
-> + Splitting EDIFACT files pipeli... (3)
-> - Problem with SAXO processor - ... (5)
-> ->Problem with SAXO process...
-> ->Problem with SAXO process...
-> ->Problem with SAXO process...
-> ->Problem with SAXO process...
-> + PDF Format Help (4)
-> + License check unreliable (2)
-> - XML related issue (1)
-> + Need help regarding pipeline o... (2)
-> + Error converting XML to EDIFAC... (4)
-> + XSLT Profiling for XSLT 1.0 s... (2)
-> + Grouping (2)
-> - Best Toner for Sensitive Skin (1)
-> + Best Practice for Pipeline err... (2)
-> + pdf generation (4)
-> + Problems excuting a Pipeline w... (2)
-> + XML serializer (3)
-> + Supported EDIFACT versions (5)
-> - Anyone know XActimate ESX file... (1)
-> + Stylus Studio with OpenJDK (2)
-> - Encoding error when importing ... (1)
-> - SEO Service in Delhi, India (1)
-> - HP Printer Support (1)
-- [1-20] [21-40] [41-60] Next
+ Website Feedback (247)
+ XSLT Help and Discussion (7615)
+ XQuery Help and Discussion (1946)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Dan OvergaardSubject: Problem with SAXO processor - XSLT test
Author: Dan Overgaard
Date: 21 Aug 2020 05:31 AM
I have a “funny little problem” when running an xslt on a xml file, using processor Saxo 9.7.0.15, that I hope someone can help to clarify what the problem are


The “Test” below return “true” (Fails) when using the SAXO processor, but return “False” when using any other processors (Which is correct)
<xsl:choose>
<xsl:when test="format-number(sum(cbc:PayableAmount) *-1,'##.00') = 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:otherwise>


From the XML file
<cac:TaxTotal>
<cbc:TaxAmount currencyID="DKK">2268.72</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="DKK">9074.88</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="DKK">2268.72</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID schemeID="urn:oioubl:id:taxcategoryid-1.3" schemeAgencyID="320">StandardRated</cbc:ID>
<cbc:Percent>25</cbc:Percent>
<cac:TaxScheme>
<cbc:ID schemeID="urn:oioubl:id:taxschemeid-1.5" schemeAgencyID="320">63</cbc:ID>
<cbc:Name>Moms</cbc:Name>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="DKK">9074.88</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="DKK">2268.72</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="DKK">11343.60</cbc:TaxInclusiveAmount>
<cbc:PrepaidAmount currencyID="DKK">11343.60</cbc:PrepaidAmount>
<cbc:PayableAmount currencyID="DKK">0.00</cbc:PayableAmount>
</cac:LegalMonetaryTotal>

Postnext
Ivan PedruzziSubject: Problem with SAXO processor - XSLT test
Author: Ivan Pedruzzi
Date: 21 Aug 2020 04:57 PM
We need to see the entire XSLT and XML input document to help.

Ivan Pedruzzi
Stylus Studio Team

Postnext
Dan OvergaardSubject: Problem with SAXO processor - XSLT test
Author: Dan Overgaard
Date: 24 Aug 2020 07:16 AM
Hi,

Please find the two files attached

/Dan


UnknownFromNemHandel_20200813163820_7b951696-d2ea-450a-a8b3-7a2629a8d843_A.xml
XML file

UnknownOIOUBL_Invoice_Schematron.xsl
XSL

Postnext
Ivan PedruzziSubject: Problem with SAXO processor - XSLT test
Author: Ivan Pedruzzi
Date: 28 Aug 2020 01:16 PM
Originally Posted: 27 Aug 2020 10:02 PM
Function format-number behaves differently across XSLT processors.

In XSLT 1.0 every number is treated as double and when adding decimal, numbers rounding occurs.

The following expression with your input does not return 0 but, rather -1.8189894035458565E-12, which is a very tiny number but not 0.

When multiply by -1 and formatted as ##.00 you get 0

sum(cbc:LineExtensionAmount) +
sum(../cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount) +
sum(cbc:ChargeTotalAmount) -
sum(cbc:AllowanceTotalAmount) -
sum(cbc:PrepaidAmount) +
sum(cbc:PayableRoundingAmount)

The following expression return -.00 which does not match the above result, therefore your = operator returns false.

format-number( sum(cbc:PayableAmount) * -1,'##.00')

The difference between MSXML and Saxon is that format-number keeps the sign even if the result is 0, you can try this simple test.

<xsl:value-of select="format-number( -0.00,'##.00')"/>

Saxon interprets the specification correctly but MSXML behaves more practically.

If you are restricted to XSLT 1.0 one possibility is to create a user defined template which wraps format-number as following


<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>


Your code will look like this

<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">
....


Does it help?

Ivan Pedruzzi
Stylus Studio Team

Posttop
Dan OvergaardSubject: Problem with SAXO processor - XSLT test
Author: Dan Overgaard
Date: 31 Aug 2020 08:59 AM
Hi Ivan,

Thanks for your answer – Very enlighting!

/Dan Overgaard

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.