Could you please give an example of your xml? I tried it out with an
xsd, an xml and a class.
The result showed me that integers were stored without formatting
(which was expected).
Joachim
This is what it looks like:
____________________
XSD:
____________________
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="TestClass" targetNamespace="
http://tempuri.org/
TestClass.xsd" elementFormDefault="qualified" xmlns="http://
tempuri.org/TestClass.xsd" xmlns:mstns="
http://tempuri.org/
TestClass.xsd" xmlns:xs="
http://www.w3.org/2001/XMLSchema">
<xs:element name="TestClass">
<xs:complexType>
<xs:sequence>
<xs:element name="Amount" type="xs:int">
</xs:element>
<xs:element name="Language" type="xs:language" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
____________________
class:
____________________
using System.Xml.Serialization;
//
// This source code was auto-generated by xsd, Version=2.0.50727.42.
//
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true,
Namespace="
http://tempuri.org/TestClass.xsd")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://
tempuri.org/TestClass.xsd", IsNullable=false)]
public partial class TestClass {
private int amountField;
private string languageField;
/// <remarks/>
public int Amount {
get {
return this.amountField;
}
set {
this.amountField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataType="language")]
public string Language {
get {
return this.languageField;
}
set {
this.languageField = value;
}
}
}
____________________
Unit test:
____________________
[Test]
public void SerializationLocalozation()
{
TestClass tc = new TestClass();
tc.Amount = 1000;
StreamWriter writerEnUS = new
StreamWriter("SerializationTest_en_US.xml");
StreamWriter writerNlNL = new
StreamWriter("SerializationTest_nl_NL.xml");
Thread.CurrentThread.CurrentCulture =
CultureInfo.GetCultureInfo("en-US");
tc.Language =
Thread.CurrentThread.CurrentCulture.ToString();
XmlSerializer xmls = new XmlSerializer(typeof(TestClass));
xmls.Serialize(writerEnUS, tc);
writerEnUS.Close();
Thread.CurrentThread.CurrentCulture =
CultureInfo.GetCultureInfo("nl-NL");
tc.Language =
Thread.CurrentThread.CurrentCulture.ToString();
xmls.Serialize(writerNlNL, tc);
writerNlNL.Close();
}
____________________
Resulting xml en-US:
____________________
<?xml version="1.0" encoding="utf-8"?>
<TestClass xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns="
http://tempuri.org/
TestClass.xsd">
<Amount>1000</Amount>
<Language>en-US</Language>
</TestClass>
____________________
Resulting xml nl-NL:
____________________
<?xml version="1.0" encoding="utf-8"?>
<TestClass xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns="
http://tempuri.org/
TestClass.xsd">
<Amount>1000</Amount>
<Language>nl-NL</Language>
</TestClass>