Reputation: 5945
the XML i would like to transform contains something like 7.3248378E7, which is not supported natively by the XSL-FO processor (ends up in NaN in the PDF file). Is there a nice way (which is the opposite of a dirty hack) to convert this number format?
Thanks a lot.
Upvotes: 1
Views: 3324
Reputation: 1730
Today I had to solve a similar problem with scientific conversion. Finally I had to write my own XSLT conversion template, because original "convertSciToNumString" from Michael Case mentioned here in some other answer have some bugs.
Here is an article about this implementation and conversion tests. http://www.orm-designer.com/article/xslt-convert-scientific-notation-to-decimal-number
Upvotes: 0
Reputation: 66714
I found this post: XSL Transform for converting from scientific notation to decimal number that provides an XSLT 1.0 stylesheet.
After including/importing the stylesheet, call the convertSciToNumString template to convert:
<xsl:call-template name="convertSciToNumString">
<xsl:with-param name="myval" select="'7.3248378E7'"/>
</xsl:call-template>
Produces: 73248378
This can be evaluated as a number and should get around your NaN issue:
<xsl:variable name="num">
<xsl:call-template name="convertSciToNumString">
<xsl:with-param name="myval" select="'7.3248378E7'"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$num"/> + 1 = <xsl:value-of select="$num + 1" />
Produces: 73248378 + 1 = 73248379
Upvotes: 1