Project

Profile

Help

Bug #4698

closed

Constructor XdmAtomicValue(decimal d) should use d.ToString(CultureInfo.InvariantCulture) instead of d.ToString()

Added by Martin Honnen over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Category:
.NET API
Sprint/Milestone:
-
Start date:
2020-08-27
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
10, 9.9, trunk
Fix Committed on Branch:
10, 9.9, trunk
Fixed in Maintenance Release:
Platforms:

Description

I have run into a problem with the construction of an xs:decimal from a .NET decimal, as I have a German version of Windows 10 usually .NET code runs with that CultureInfo for that language meaning in

    public XdmAtomicValue(decimal d)
    {
        this.value = new JBigDecimalValue(new JBigDecimal(d.ToString()));
    }

the call of d.ToString() where var d = 2.5m; gives 2,5 and not 2.5. Subsequently the Java parsing of the 2,5 fails with

Unbehandelte Ausnahme: java.lang.NumberFormatException
   bei java.math.BigDecimal..ctor(Char[] in, Int32 offset, Int32 len, MathContext mc)
   bei java.math.BigDecimal..ctor(Char[] in, Int32 offset, Int32 len)
   bei java.math.BigDecimal..ctor(String val)
   bei Saxon.Api.XdmAtomicValue..ctor(Decimal d)

So I think the constructor needs to be fixed to use d.ToString(CultureInfo.InvariantCulture).

Actions #1

Updated by Community Admin over 3 years ago

  • Status changed from New to In Progress

hi Martin,

Thank you for raising this issue and for the suggestion. Currently investigating and testing the patch.

Actions #2

Updated by Community Admin over 3 years ago

  • Assignee set to O'Neil Delpratt
Actions #3

Updated by O'Neil Delpratt over 3 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100
  • Fix Committed on Branch 10, 9.9 added

Bug fixed applied as suggested in the comment 0. Adding test case to nunit.

Actions #6

Updated by O'Neil Delpratt over 3 years ago

  • Applies to branch trunk added
  • Fix Committed on Branch trunk added
Actions #8

Updated by O'Neil Delpratt over 3 years ago

  • Status changed from Resolved to In Progress
Actions #9

Updated by O'Neil Delpratt over 3 years ago

  • Status changed from In Progress to Resolved

Added nunit test case. Bug fix available in the next maintenance release.

Actions #10

Updated by O'Neil Delpratt over 3 years ago

  • Status changed from Resolved to In Progress
Actions #12

Updated by O'Neil Delpratt over 3 years ago

  • Status changed from In Progress to Resolved

Bug fixed, but the only way to test it was to change the regional settings in Windows, which was not ideal.

Actions #13

Updated by Martin Honnen over 3 years ago

It should suffice to set e.g. CultureInfo.CurrentCulture = new CultureInfo("de-de") in your C# code to hit the problem, without needing to change the Windows settings.

Actions #14

Updated by O'Neil Delpratt over 3 years ago

  • Fixed in Maintenance Release 9.9.1.8 added

Bug fix applied on the Saxon 9.9.1.8 maintenance release. Leaving open until applied on the Saxon 10 maintenance release.

Actions #15

Updated by O'Neil Delpratt over 3 years ago

Bug fix applied in the Saxon 10.3 maintenance release

Actions #16

Updated by O'Neil Delpratt over 3 years ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 10.3 added

Please register to edit this issue

Also available in: Atom PDF