[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Working with Scientific Notation
Just to sort of wrap this up, this is the solution I came up (many
thanks to David Carlisle for the real meat of this solution).
The problem was that Excel's ss:Data nodes sometime come in scientific notation, and sometimes as non-scientific notation numbers. Here it is, you could easilly call it by doing something like: <xsl:call-template name="Scientific"> <xsl:with-param name="Num" select="."/> </xsl:call-template> It handles the number whether or not the scientific notation is part of the number. <xsl:template name="Scientific"> <xsl:param name="Num"/> <xsl:if test="boolean(number(substring-after($Num,'E')))"> <xsl:call-template name="Scientific_Helper"> <xsl:with-param name="m" select="substring-before($Num,'E')"/> <xsl:with-param name="e" select="substring-after($Num,'E')"/> </xsl:call-template> </xsl:if> <xsl:if test="not(boolean(number(substring-after($Num,'E'))))"> <xsl:value-of select="$Num"/> </xsl:if> </xsl:template> <xsl:template name="Scientific_Helper"> <xsl:param name="m"/> <xsl:param name="e"/> <xsl:choose> <xsl:when test="$e = 0 or not(boolean($e))"> <xsl:value-of select="$m"/> </xsl:when> <xsl:when test="$e > 0"> <xsl:call-template name="Scientific_Helper"> <xsl:with-param name="m" select="$m * 10"/> <xsl:with-param name="e" select="$e - 1"/> </xsl:call-template> </xsl:when> <xsl:when test="$e < 0"> <xsl:call-template name="Scientific_Helper"> <xsl:with-param name="m" select="$m div 10"/> <xsl:with-param name="e" select="$e + 1"/> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:template> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|