HighTechTalks DotNet Forums  

format-number format string incompatability

Dotnet XML microsoft.public.dotnet.xml


Discuss format-number format string incompatability in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Richard Haber
 
Posts: n/a

Default format-number format string incompatability - 04-10-2004 , 09:19 PM






I am using format-number(-1234.56,'#,##0.00;(#,##0.00)') in a stylesheet
that works in every xsl processor (including MSXML2) except for the one in
..NET 1.1. I am expecting to see (1,234.56) as the result of this function,
but am getting an ArgumentException : NumberGroupSizes error with the
message "Parameter name: Every element in the value array should be between
one and nine, except for the last, which can be zero"

If I use just '(#,##0.00)' as the format, it gives me the expected result
(for both positive and negatives numbers) so it seems to be the second part
of the format after the ';'

Can anyone shed any light on this or suggest a viable workaround.

Thanks for the time



Reply With Quote
  #2  
Old   
Derek Harmon
 
Posts: n/a

Default Re: format-number format string incompatability - 04-11-2004 , 12:24 PM






"Richard Haber" <richard_haber (AT) hotmail (DOT) com> wrote

Quote:
I am using format-number(-1234.56,'#,##0.00;(#,##0.00)') in a stylesheet
that works in every xsl processor (including MSXML2) except for the one in
.NET 1.1. I am expecting to see (1,234.56) as the result of this function,
but am getting an ArgumentException : NumberGroupSizes error with the
message "Parameter name: Every element in the value array should be between
one and nine, except for the last, which can be zero"
: :
Can anyone shed any light on this or suggest a viable workaround.
- - - workaround.xsl (excerpt)
<!-- . . . -->
<xsl:template name="formatNumber">
<xslaram name="num" />
<xsl:choose>
<xsl:when test="number($num) &lt; 0">
<xsl:value-of select="format-number( number($num), '(#,##0.00)')" />
</xsl:when>
<xsl:when test="number($num) &gt;= 0">
<xsl:value-of select="format-number( number($num), '#,##0.00')" />
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- . . . -->
<xsl:call-template name="formatNumber">
<xsl:with-param name="num" select="-1234.56" />
</xsl:call-template>
<!-- . . . -->
- - -


Derek Harmon




Reply With Quote
  #3  
Old   
Richard Haber
 
Posts: n/a

Default Re: format-number format string incompatability - 04-11-2004 , 03:30 PM



Thanks for the quick response. This is a viable workaround.

Still left wondering why the .NET XSL classes seem to have been 'dumbed
down' from the rest of the XSLT Processors. Other Microsoft products have
extensive support for number formatting, e.g., Excel, so this can't be
unknown territory for them

"Derek Harmon" <loresayer (AT) msn (DOT) com> wrote

Quote:
"Richard Haber" <richard_haber (AT) hotmail (DOT) com> wrote

I am using format-number(-1234.56,'#,##0.00;(#,##0.00)') in a stylesheet
that works in every xsl processor (including MSXML2) except for the one
in
.NET 1.1. I am expecting to see (1,234.56) as the result of this
function,
but am getting an ArgumentException : NumberGroupSizes error with the
message "Parameter name: Every element in the value array should be
between
one and nine, except for the last, which can be zero"
: :
Can anyone shed any light on this or suggest a viable workaround.

- - - workaround.xsl (excerpt)
!-- . . . --
xsl:template name="formatNumber"
xslaram name="num" /
xsl:choose
xsl:when test="number($num) &lt; 0"
xsl:value-of select="format-number( number($num),
'(#,##0.00)')" /
/xsl:when
xsl:when test="number($num) >= 0"
xsl:value-of select="format-number( number($num),
'#,##0.00')" /
/xsl:when
/xsl:choose
/xsl:template
!-- . . . --
xsl:call-template name="formatNumber"
xsl:with-param name="num" select="-1234.56" /
/xsl:call-template
!-- . . . --
- - -


Derek Harmon





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.