Subject: RE: [xsl] Unexpected Results with format-number() From: "Angela Williams" <Angela.Williams@xxxxxxxxxxxxxxxxxx> Date: Thu, 16 Aug 2007 09:35:49 -0500 |
Thanks - do you want me to submit this to the Saxon list? And the format I sent actually has 2 hash signs between the comma and the period - it looks like they were filtered out between me sending the email and the list forwarding it on.... Thanks! Angela -----Original Message----- From: Michael Kay [mailto:mike@xxxxxxxxxxxx] Sent: Thursday, August 16, 2007 4:11 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Unexpected Results with format-number() When I run your code on Saxon 8.9.0.4 I get: Error on line 27 of file:/c:/temp/test.xsl: XTDE1310: format-number picture: Cannot have a grouping separator adjacent to the decimal separator After fixing that, there does seem to be a Saxon problem: a number that is equal to zero after rounding to the required number of digits is displayed as 0, not as 0.00. The problem appears to be present in 8.9.0.4 but not in 8.9.0.3, so it shouldn't be hard to track down. Michael Kay http://www.saxonica.com > -----Original Message----- > From: Angela Williams [mailto:Angela.Williams@xxxxxxxxxxxxxxxxxx] > Sent: 16 August 2007 00:20 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Unexpected Results with format-number() > > I've just noticed a difference in the way small numbers are > formatting. > When I wrote this a few weeks ago, small numbers formatted with the > correct precision. Now it seems the format string is being ignored. > > I believe I was using Saxon 8.8 when I first wrote the code. > I updated to Saxon 8.9.0.4 yesterday, but that may just be a > coincidence. > > What am I missing? > > Sample XML: > <?xml version="1.0" encoding="UTF-8"?> <values> > <amt>-0.003000</amt> > <amt>-0.001500</amt> > <amt>0.003000</amt> > <amt>0.00</amt> > <amt>0</amt> > </values> > > Expected output: > amt: [-0.003] formatted-value: [-$0.00] > amt: [-0.0015] formatted-value: [-$0.00] > amt: [0.003] formatted-value: [$0.00] > amt: [0] formatted-value: [$0.00] > amt: [0] formatted-value: [$0.00] > > Actual output: > amt: [-0.003] formatted-value: [-$0] > amt: [-0.0015] formatted-value: [-$0] > amt: [0.003] formatted-value: [$0] > amt: [0] formatted-value: [$0] > amt: [0] formatted-value: [$0] > > Stylesheet: > <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:fk="http://www.the401kcompany.com/functions" > version="2.0"> > > <xsl:template match="/values"> > <html> > <body> > <xsl:apply-templates select="amt" /> > </body> > </html> > </xsl:template> > > <xsl:template match="amt"> > <p> > <xsl:value-of select="fk:nbr-format(.)" /> > </p> > </xsl:template> > > <xsl:function name="fk:nbr-format"> > <xsl:param name="amt" as="xs:double" /> > <xsl:variable name="picture" select="'$,.00'" /> > amt: [<xsl:value-of select="$amt" />] > formatted-value: [<xsl:value-of > select="format-number(number($amt), string($picture))" />] > </xsl:function> > </xsl:stylesheet> > > Thanks! > Angela Williams > Software Developer > The 401k Company, A Charles Schwab Company > 98 San Jacinto Blvd. ~ Suite 1100 ~ Austin, TX 78701 > Office: 512.344.1547 ~ Fax: 512.397.6656 > Angela.Williams@xxxxxxxxxxxxxxxxxx
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Unexpected Results with f, Michael Kay | Thread | [xsl] How to extract HTTP Headers i, Zulfikar Dholkawala |
Re: [xsl] Re: XML/XHTML fragment to, Abel Braaksma | Date | Re: [xsl] Re: XML/XHTML fragment to, Abel Braaksma |
Month |