RE: [xsl] format-number

Subject: RE: [xsl] format-number
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 26 Feb 2003 16:41:30 -0500
At 2003-02-26 16:30 -0500, Michael Semcheski wrote:
I believe the poster was looking for information on whether a value passed
to format-number() that is not a number could be made to return something
other than NaN.

I would be interested if anyone could comment.

If that is truly what the poster was asking for, that is what <xsl:decimal-format> is for. An example is below.

I hope this helps.

................ Ken

T:\ftemp>type semcheski.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="";

<xsl:output method="text"/>

<xsl:decimal-format name="michael" NaN="not a nice number"/>

<xsl:template match="/">
  A:  <xsl:value-of select="format-number( 1.23, '#.000', 'michael' )"/>
  B:  <xsl:value-of select="format-number( 'ab', '#.000', 'michael' )"/>
  C:  <xsl:value-of select="format-number( 2.34, '#.000', 'michael' )"/>


T:\ftemp>saxon semcheski.xsl semcheski.xsl

  A:  1.230
  B:  not a nice number
  C:  2.340

Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO
                             North America:      June 16-20, 2003

G. Ken Holman                mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                      Definitive XSLT and XPath
ISBN 0-13-140374-5                              Definitive XSL-FO
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-10-1              Practical Formatting Using XSL-FO
Male Breast Cancer Awareness

XSL-List info and archive:

Current Thread