[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Working with Scientific Notation

Subject: Re: Working with Scientific Notation
From: "Michael H. Semcheski" <mhs-list@xxxxxxxxx>
Date: Fri, 04 Oct 2002 14:34:01 -0400
scientific notation names
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 &gt; 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 &lt; 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.