On 6/14/06, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
> is it true that msxml processor does not treat the floating point
> numbers (with scientific notation) like 1.234e-3 as numeric values.
yes the same is true of all XSLT1 processors. 1.234e-3 is a syntax
error in XPath1 (it is floating point syntax in XPath2)
> my client application uses the msxml (Internet explorer 6).
> is there any workaround to make it work.
in pure xslt use substring-after to split on the e and then multiply or
divide by 10 the specified number of times.
thanks for the inputs.
I managed to get it woking.. (although bit lengthy... as i dint find
any other option :)- )
theXML:
<root>
<elemOne>1.234e-3</elemOne>
<elemTwo>200</elemTwo>
</root>
theXSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="root">
<result>
<val>
<xsl:call-template
name="multiplySciNumWithOther">
<xsl:with-param name="paramOneBase"
select="substring-before(elemOne,'e')"/>
<xsl:with-param name="paramOnePower"
select="substring-after(elemOne,'e')"/>
<xsl:with-param name="paramTwo"
select="elemTwo"/>
</xsl:call-template>
</val>
</result>
</xsl:template>
<xsl:template name="multiplySciNumWithOther">
<xsl:param name="paramOneBase" select="0"/>
<xsl:param name="paramOnePower" select="0"/>
<xsl:param name="paramTwo" select="1"/>
<xsl:if test="$paramOnePower > 0">
<xsl:call-template name="multiplySciNumWithOther">
<xsl:with-param name="paramOneBase"
select="$paramOneBase * 10"/>
<xsl:with-param name="paramOnePower"
select="$paramOnePower - 1"/>
<xsl:with-param name="paramTwo"
select="$paramTwo"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$paramOnePower < 0">
<xsl:call-template name="multiplySciNumWithOther">
<xsl:with-param name="paramOneBase"
select="$paramOneBase div 10"/>
<xsl:with-param name="paramOnePower"
select="$paramOnePower + 1"/>
<xsl:with-param name="paramTwo"
select="$paramTwo"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$paramOnePower = 0">
<xsl:value-of select="$paramOneBase * $paramTwo"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
transformedXML:
<result>
<val>0.24680000000000002</val>
</result>
David
--
Kind Regards,
Jagdishwar B.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--