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

Re: [xsl] format-number in XSLT 1.0

Subject: Re: [xsl] format-number in XSLT 1.0
From: Jack Matheson <jack@xxxxxxxxxxxxxx>
Date: Wed, 26 Jan 2005 11:00:17 -0600

Many thanks for the great explanation!
format-number-1.0 was exactly what I was looking for.

The Xalan result is conformant with the XSLT 1.0 specification if you adopt
a generous interpretation of the spec; the Saxon 8.2 result is conformant
with the XSLT 2.0 specification.

In XSLT 1.0 format-number() was specified by reference to the JDK 1.1
specification of the DecimalFormat class. Unfortunately the JDK 1.1
documentation was very vague in a number of areas. The statement that the
negative subpicture is largely ignored appeared in the JDK documentation
only in later versions. It's very likely that an XSLT 1.0 implementation
built using Java will behave the way DecimalFormat actually behaves in the
version of Java that you are using, while an implementation built in a
different language is likely to do what a reader of the JDK 1.1
specification might have expected, namely that the negative subpicture means
what it says.

In XSLT 2.0 we decided to remove the dependency on the Java specification
and write a free-standing specification for format-number. In doing this, we
had to decide whether to make it behave the way Java behaved, or the way JDK
1.1 said it should behave; and by-and-large we chose the latter, because
that is what non-Java XSLT implementations are likely to have implemented.

So XSLT 2.0 doesn't carry forward this Java anomaly regarding negative
patterns. This is documented as something that may cause incompatible
behavior on some implementations, though since XSLT 1.0 is underspecified in
this area that's outside the control of the spec.

Saxon 8.2 has a free-standing implementation of format-number that doesn't
rely on the Java DecimalFormat class, so it should do exactly what XSLT 2.0

If you need it, the old implementation remains available in Saxon 8.2 for
the time being under the name format-number-1.0().

Current Thread