Project

Profile

Help

exponential notation sometimes

Added by Anonymous about 15 years ago

Legacy ID: #6886213 Legacy Poster: saby323 (sabyasachi323)

Hi, While doing a simple xslt processing I see my integer value or long values are being converted to exponential notation. Please let me know how can I retain the original values. My input xml has an element : <ComprimeringsCode>1111600</ComprimeringsCode> In my xsl : <Comprimeringscode> <xsl:value-of select="./Comprimering/ComprimeringsCode"/> </Comprimeringscode> In my output string this is sometimes represented as 1.1116E and some times as 1111600. Please advice as how can I solve this problem. Thanks in advance. Regards, Saby..


Replies (4)

Please register to reply

RE: exponential notation sometimes - Added by Anonymous about 15 years ago

Legacy ID: #6886812 Legacy Poster: Michael Kay (mhkay)

I assume you are using Saxon-B, so the input has not been validated against a schema. If you simply use xsl:value-of in the way shown, the value of the node is never converted to a number, so it will be output exactly as in the input. If you do some numeric manipulation, for example adding 1 to the value, then this may be done using integer or floating-point arithmetic depending on the exact expression that you use, and depending on whether the stylesheet is in backwards-compatible mode (version="1.0") or not. If you use floating-point arithmetic, then the result will be output in exponential notation if it is outside the range 1e-6 to 1e+6. If you use integer arithmetic, it will be output as an integer. You can force it to be output as an integer by using format-number(), or simply by casting to xs:integer - but it may be better to use integer arithmetic in the first place. This is really a question about the XSLT language, not about Saxon. So it really belongs on the xsl-list at mulberrytech.com.

RE: exponential notation sometimes - Added by Anonymous about 15 years ago

Legacy ID: #6887050 Legacy Poster: saby323 (sabyasachi323)

Hi, Yes indeed I am using Saxon-B. Sorry that i gave a wrong example : But, my situation is like this, with(version="1.0"): My xsl: <TermFloorLimitIcc> <xsl:if test="string(number(./MerchantBetaalproductParameter/OfflineFloorLimitIcc)) != 'NaN'"> <xsl:value-of select="round(number(./MerchantBetaalproductParameter/OfflineFloorLimitIcc)*100)"/> </xsl:if> </TermFloorLimitIcc> My xml: <OfflineFloorLimitIcc>22225</OfflineFloorLimitIcc> Now when I place xalan.jar in the classpath , I have this ouptut: <TermFloorLimitIcc>2222500</TermFloorLimitIcc> But, with saxon9.jar in the classpath ,I have this output: <TermFloorLimitIcc>2.2225E6</TermFloorLimitIcc>. We moved from xalan.jar to saxon9.jar because of a committed virtual memory problem in xalan. But, with saxon9 we are encountering this problem. Please advice.

RE: exponential notation sometimes - Added by Anonymous about 15 years ago

Legacy ID: #6887182 Legacy Poster: Michael Kay (mhkay)

This is a documented incompatibility between XSLT 1.0 and XSLT 2.0. It is documented here: http://www.w3.org/XML/2007/qt-errata/xpath20-errata.html#E2 (see change 2, the new list item 6) To solve this problem, I would suggest formatting the number using format-number().

RE: exponential notation sometimes - Added by Anonymous about 15 years ago

Legacy ID: #6887797 Legacy Poster: saby323 (sabyasachi323)

Thank you . It solved my problem.

    (1-4/4)

    Please register to reply