Project

Profile

Help

Bug #4698

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

Added by Martin Honnen over 1 year ago. Updated about 1 year 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).

History

#1 Updated by Community Admin over 1 year 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.

#2 Updated by Community Admin over 1 year ago

  • Assignee set to O'Neil Delpratt

#3 Updated by O'Neil Delpratt about 1 year 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.

#6 Updated by O'Neil Delpratt about 1 year ago

  • Applies to branch trunk added
  • Fix Committed on Branch trunk added

#8 Updated by O'Neil Delpratt about 1 year ago

  • Status changed from Resolved to In Progress

#9 Updated by O'Neil Delpratt about 1 year ago

  • Status changed from In Progress to Resolved

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

#10 Updated by O'Neil Delpratt about 1 year ago

  • Status changed from Resolved to In Progress

#12 Updated by O'Neil Delpratt about 1 year 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.

#13 Updated by Martin Honnen about 1 year 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.

#14 Updated by O'Neil Delpratt about 1 year 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.

#15 Updated by O'Neil Delpratt about 1 year ago

Bug fix applied in the Saxon 10.3 maintenance release

#16 Updated by O'Neil Delpratt about 1 year 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