Since we use the C run-time libraries for doing conversions, setting
locales would probably screw up our conversion routines.  I'll take a look
at the code and see if I can't do a quick fix.

Dave



                                                                                       
                       
                    Holger Fl"rke                                                      
                       
                    <floerke@doct        To:     [EMAIL PROTECTED]              
                       
                    ronic.de>            cc:     (bcc: David N Bertoni/CAM/Lotus)      
                       
                                         Subject:     Xalan-C, Floating Numbers 
depends on locale setings     
                    05/25/2001                                                         
                       
                    05:33 AM                                                           
                       
                    Please                                                             
                       
                    respond to                                                         
                       
                    xalan-dev                                                          
                       
                                                                                       
                       
                                                                                       
                       



I have a problem with floating-point numbers. The representation in XSL
should be always with a dot (".") as the decimal separator. I am using the
"iso-8859-1" locale with a comma (",") as the decimal separator. If I try
to calculate with floating point numbers in Xalan-C (see example below) it
works until I set the current locale with "setlocal(LC_ALL,"")" before
initializing XMLPlatformUtils.

There was another thread in xalan-dev from March, 26 (Subject: Math
Problem?) related to this bug and saying the bug will be committed to the
bug database. But I didn't find a bug report to this problem (Indeed I
found only 23 bugs in the database related to Xalan-C :^| )

So I ask you: Are there fixes for Xalan-C1.1? Or can you show me where
floating-point conversion in Xalan takes place?

TIA

HolgeR

XML
===
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<HitList maxscore="4.267560"/>
<Hit score="3.727572"/>
</root>


XSL(T)
======
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                 version="1.0">

   <xsl:template match="/root">
     <a>
       Score: <xsl:value-of select="./Hit/@score"/>
       MaxScore: <xsl:value-of select="./HitList/@maxscore"/>
       Res: <xsl:value-of select="round(number(./Hit/@score)
div  number(./HitList/@maxscore) * 100)"/>
     </a>
   </xsl:template>

</xsl:stylesheet>

Test-Program
============
#include <util/PlatformUtils.hpp>
#include <XalanTransformer/XalanTransformer.hpp>

#include <iostream>
#include <locale.h>
using namespace std;

int  main(int argc, char* argv[])
{
   setlocale(LC_ALL,""); // this line leads to trouble
   XMLPlatformUtils::Initialize();
   XalanTransformer::initialize();

   XalanTransformer oTheTransformer;

   oTheTransformer.transform("float.xml","float.xsl",cout);
   XalanTransformer::terminate();

   XMLPlatformUtils::Terminate();

}


Result without Locale (the right way):
======================================
<?xml version="1.0" encoding="UTF-8"?>
<a>
Score: 3.727572
MaxScore: 4.267560
Res: 87
</a>

Result wit Locale (the wrong way):
==================================
<?xml version="1.0" encoding="UTF-8"?>
<a>
Score: 3.727572
MaxScore: 4.267560
Res: 75,
</a>


--
holger floerke                      d  o  c  t  r  o  n  i  c
email [EMAIL PROTECTED]          information publishing + retrieval
phone +49 (0) 2222 9292 90          http://www.doctronic.de
fax   +49 (0) 2222 9292 99





Reply via email to