Fw: xslt and number formats

2001-11-29 Thread Brian T. Wolf

Sorry this is probably not the most appropriate forum, but I have looked
everywhere I can think of. If anyone on this list can point me in the right
direction I would be grateful.
Thanks,
Brian
- Original Message -
From: "Brian T. Wolf" <[EMAIL PROTECTED]>
Newsgroups: comp.text.xml
Sent: Tuesday, November 27, 2001 2:04 PM
Subject: xslt and number formats


> OK, I am at my wits' end. I have looked at various sites, specs, and
> FAQ's, and I just am not getting an understanding of number
> formatting. I am using templates to transform my XML data into a table
> after which I will have column totals. I am using the sum() function
> and the math seems to be working as expected - with one minor hitch:
> the decimals are being truncated. Since I am printing invoices dealing
> with currency it is essential that the decimals remain down to the
> penny. Can someone explain this in clear English for me, or else point
> me somewhere I may not have yet seen?
>
> sample XML:
> 
>  
>   Federal Excise Tax
>   2.25
>  
>  
>   State 911 Emergency Tax
>   0.54
>  
> 
>
> sample XSL:
> 
>  
>  
>   
>
> 
>
>   
>  
>  
> 
>
> I am using xalan-2.0.0 for the transformation, if that makes a
> difference.
>
> Thanks much,
> Brian

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




RE: xslt and number formats

2001-11-29 Thread Ramin Firoozye

Hi Brian,

I tried your code in Xalan (C and J) and MSXML and got '2.79' (with the
digits after decimal point intact). The XSLT spec says that numbers are kept
in double format internally so you shouldn't be getting any truncation loss
as a result of doing math. The 'sum' function is also supposed to keep
numbers in their original format. The only culprit may be the xsl:value-of
instruction (although on my system, it's working fine). You might want to
try to force a format using something like:



The '#' characters default to the formatting scheme defined in the JDK 1.1
java.text.DecimalFormat class
<http://java.sun.com/products/jdk/1.1/docs/api/java.text.DecimalFormat.html>
.

Hope this helps,
Ramin

>
>
> Sorry this is probably not the most appropriate forum, but I have looked
> everywhere I can think of. If anyone on this list can point me in
> the right
> direction I would be grateful.
> Thanks,
> Brian
> - Original Message -
> From: "Brian T. Wolf" <[EMAIL PROTECTED]>
> Newsgroups: comp.text.xml
> Sent: Tuesday, November 27, 2001 2:04 PM
> Subject: xslt and number formats
>
>
> > OK, I am at my wits' end. I have looked at various sites, specs, and
> > FAQ's, and I just am not getting an understanding of number
> > formatting. I am using templates to transform my XML data into a table
> > after which I will have column totals. I am using the sum() function
> > and the math seems to be working as expected - with one minor hitch:
> > the decimals are being truncated. Since I am printing invoices dealing
> > with currency it is essential that the decimals remain down to the
> > penny. Can someone explain this in clear English for me, or else point
> > me somewhere I may not have yet seen?
> >
> > sample XML:
> > 
> >  
> >   Federal Excise Tax
> >   2.25
> >  
> >  
> >   State 911 Emergency Tax
> >   0.54
> >  
> > 
> >
> > sample XSL:
> > 
> >  
> >  
> >   
> >
> > 
> >
> >   
> >  
> >  
> > 
> >
> > I am using xalan-2.0.0 for the transformation, if that makes a
> > difference.
> >
> > Thanks much,
> > Brian
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




Re: xslt and number formats

2001-11-29 Thread Brian T. Wolf

Silly me, the sample I included in the message is not what I was really
using. Instead of  I was really
using . The "value-of" does seem
to work better - thanks!
I still need to include your suggestion for the "format-number", however if
I use  after the decimal as you suggest then trailing zeroes are
omitted. So instead I have put in 0.00 and that seems to do the trick.
-Brian
- Original Message -
From: "Ramin Firoozye" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 29, 2001 9:24 AM
Subject: RE: xslt and number formats


> Hi Brian,
>
> I tried your code in Xalan (C and J) and MSXML and got '2.79' (with the
> digits after decimal point intact). The XSLT spec says that numbers are
kept
> in double format internally so you shouldn't be getting any truncation
loss
> as a result of doing math. The 'sum' function is also supposed to keep
> numbers in their original format. The only culprit may be the xsl:value-of
> instruction (although on my system, it's working fine). You might want to
> try to force a format using something like:
>
> 
>
> The '#' characters default to the formatting scheme defined in the JDK 1.1
> java.text.DecimalFormat class
>
<http://java.sun.com/products/jdk/1.1/docs/api/java.text.DecimalFormat.html>
> .
>
> Hope this helps,
> Ramin

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]