You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by lijun zou <li...@yahoo.com> on 2004/05/13 03:45:27 UTC

format-number rounding error

Hi, I am trying to generate PDF using FOP. 
But I got a rounding error when using the following
fo script
<fo:block>
<xsl:value-of select="format-number(0.5,'0')"/>
</fo:block>

The result from fop is
0
instead of 
1

Is this a bug?
How do we get around of it?

Thanks

LZ


	
		
__________________________________
Do you Yahoo!?
Yahoo! Movies - Buy advance tickets for 'Shrek 2'
http://movies.yahoo.com/showtimes/movie?mid=1808405861 

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


RE: format-number rounding error

Posted by "Andreas L. Delmelle" <a_...@pandora.be>.
> -----Original Message-----
> From: Chris Bowditch [mailto:bowditch_chris@hotmail.com]
>
> lijun zou wrote:
>
> > No, It is an error.
> > '0' is a pattern, meaning round to integer.
>
> Perhaps you are right. But this is really the wrong
> forum for this question as its a pure xslt question.
> You will get better answers on the xsl-list:

Hi,

A pure XSLT question indeed, but I'm wondering why the OP doesn't simply use
the round() function (which does *exactly* what he needs)


Cheers,

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: format-number rounding error

Posted by Chris Bowditch <bo...@hotmail.com>.
lijun zou wrote:

> No, It is an error.
> '0' is a pattern, meaning round to integer.

Perhaps you are right. But this is really the wrong forum for this question as 
its a pure xslt question. You will get better answers on the xsl-list:

http://lists.mulberrytech.com/xsl-list/

> I use other formatter, the result is ok.

Its the XSLT processor that is responsible for the format-number() function, 
FOP uses Xalan by default. What XSLT processor is this other formatter using?

<snip/>

Chris



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: format-number rounding error

Posted by lijun zou <li...@yahoo.com>.
No, It is an error.
'0' is a pattern, meaning round to integer.
I use other formatter, the result is ok.

--- Chris Bowditch <bo...@hotmail.com> wrote:
> lijun zou wrote:
> 
> > Hi, I am trying to generate PDF using FOP. 
> > But I got a rounding error when using the
> following
> > fo script
> > <fo:block>
> > <xsl:value-of select="format-number(0.5,'0')"/>
> > </fo:block>
> 
> This is not a "rounding error" You have specified
> your format to be "0", so 
> the string "0" is always output. I think what you
> need is:
> 
> <xsl:value-of
> select="format-number(0.5,'#,##0.0')"/>
> 
> <snip/>
> 
> Chris
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> fop-user-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> fop-user-help@xml.apache.org
> 



	
		
__________________________________
Do you Yahoo!?
Yahoo! Movies - Buy advance tickets for 'Shrek 2'
http://movies.yahoo.com/showtimes/movie?mid=1808405861 

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: format-number rounding error

Posted by Chris Bowditch <bo...@hotmail.com>.
lijun zou wrote:

> Hi, I am trying to generate PDF using FOP. 
> But I got a rounding error when using the following
> fo script
> <fo:block>
> <xsl:value-of select="format-number(0.5,'0')"/>
> </fo:block>

This is not a "rounding error" You have specified your format to be "0", so 
the string "0" is always output. I think what you need is:

<xsl:value-of select="format-number(0.5,'#,##0.0')"/>

<snip/>

Chris



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org