EXSLT - math:constant - XSLT Template Implementation

Supported Version: 1
XML Definition: math.constant.xml
Source: math.constant.template.xsl

Source

<xsl:template name="math:constant">
   <xsl:param name="name"
              select="/.." />
   <xsl:param name="precision"
              select="/.." />
   <xsl:choose>
      <xsl:when test="$name='PI'">
         <xsl:variable name="return">3.1415926535897932384626433832795028841971693993751</xsl:variable>
         <xsl:value-of select="substring($return,1,$precision)" />
      </xsl:when>
      <xsl:when test="$name='E'">
         <xsl:variable name="return">2.71828182845904523536028747135266249775724709369996</xsl:variable>
         <xsl:value-of select="substring($return,1,$precision)" />
      </xsl:when>
      <xsl:when test="$name='SQRRT2'">
         <xsl:variable name="return">1.41421356237309504880168872420969807856967187537694</xsl:variable>
         <xsl:value-of select="substring($return,1,$precision)" />
      </xsl:when>
      <xsl:when test="$name='LN2'">
         <xsl:variable name="return">0.69314718055994530941723212145817656807550013436025</xsl:variable>
         <xsl:value-of select="substring($return,1,$precision)" />
      </xsl:when>
      <xsl:when test="$name='LN10'">
         <xsl:variable name="return">2.302585092994046</xsl:variable>
         <xsl:value-of select="substring($return,1,$precision)" />
      </xsl:when>
      <xsl:when test="$name='LOG2E'">
         <xsl:variable name="return">1.4426950408889633</xsl:variable>
         <xsl:value-of select="substring($return,1,$precision)" />
      </xsl:when>
      <xsl:when test="$name='SQRT1_2'">
         <xsl:variable name="return">0.7071067811865476</xsl:variable>
         <xsl:value-of select="substring($return,1,$precision)" />
      </xsl:when>
   </xsl:choose>
</xsl:template>

Change History

Submitted: 2001-05-23
Creator: James Fuller(http://www.ruminate.co.uk)

Returns a variety of standard mathematical constants.
VersionModifiedByDetails
1.12002-08-21Craig Stewart

Added 4XSLT and libxslt implementation to the list.

1.22002-11-12Craig Stewart

Updated 4XSLT version to 0.12.0a3.

http://www.exslt.org/math/functions/constant/math.constant.template.xsl.html last modified 2002-11-12