[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: Formatting Numbers and Dates


Subject: RE: Formatting Numbers and Dates
From: "Emery, Ric" <ric.emery@xxxxxxx>
Date: Thu, 5 Aug 1999 09:14:21 -0700

Not sure about formatting dates.

Formatting numbers can be achieved with the format-number function of XSL.
This function is described in section 14.3 of the latest XSL spec.

Here is an example that formats a variable to 2 decimal places.

<xsl:value-of select="format-number ($SOMENUMBER, '0.00')" />

-----Original Message-----
From: Senthil Vaiyapuri [mailto:senthil@xxxxxxxxxx]
Sent: Friday, July 23, 1999 8:26 AM
To: 'xsl-list@xxxxxxxxxxxxxxxx'
Subject: Formatting Numbers and Dates



  Howdy,

     Are there builtin ways (methods) available in XSL to format
     numbers and Dates?  With IE5, I could use formatNumber()
     and formatDate() methods (as shown below).  But this
     apparent extenstion (<xsl-eval>) makes the style sheet not
     portable.

				/* DATE_F - contains a unix time() value */

     <xsl:apply-templates select="DATE_F">
     <xsl:template match="DATE_F">
          <TD align="center">
		<FONT size="2"><xsl:eval>formatDate(new
Date(parseInt(this.text) * 1000).getVarDate(), "MMM dd
yyyy")</xsl:eval></FONT>
          </TD>
     </xsl:template>
     </xsl:apply-templates>

				/* NUM_F contains a decimal, with no
trailing zeroes */
    <xsl:apply-templates select="NUM_F">
    <xsl:template match="NUM_F">
          <TD align="center">
		<FONT size="2"><xsl:eval>formatNumber(this.nodeTypedValue,
"0.00")</xsl:eval></FONT>
          </TD>
    </xsl:template>
    </xsl:apply-templates>


     Thanks in advance..
     -senthil

----------------------------------------------------------------------------
---------
Senthil Vaiyapuri
408-861-4691
Portal Software


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


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



Current Thread
Keywords
xsl