This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Working with Scientific Notation


probably one of the libraries has something for this, but otherwise
something like

<xsl:template name="s">
  <xsl:param name="m"/>
  <xsl:param name="e"/>
  <xsl:choose>
   <xsl:when test="$e=0"><xsl:value-of select="$m"/></xsl:when>
   <xsl:when test="$e &gt;0>
    <xsl:call-template name="s">
      <xsl:param name="m" select="$m * 10"/>
     <xsl:param name="e" select="$e - 1""/>
   </xsl:call-template>
  </xsl:when>
   <xsl:when test="$e &lt;0>
    <xsl:call-template name="s">
      <xsl:param name="m" select="$m div 10"/>
     <xsl:param name="e" select="$e + 1""/>
   </xsl:call-template>
  </xsl:when>
  </xsl:choose>
</xsl:template>


<xsl:variable name="f">
    <xsl:call-template name="s">
      <xsl:param name="m" select="substring-before(.,'E')"/>
     <xsl:param name="e" select="substring-after(.,'E')""/>
   </xsl:call-template>
</xsl;variable>


then use format-number on the result, $f if you want a particular format.

untested...

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]