I'm using xml2code library to convert xsd file to C# code.
In Generator.xs file, the following code is mapping the xsd types to C# types:
var importer = new XmlSchemaImporter(schemas, generationOptions, new ImportContext(new CodeIdentifiers(), false));
foreach (XmlSchemaType type in xsd.Items.OfType<XmlSchemaType>())
{
var mapping = importer.ImportSchemaType(type.QualifiedName);
exporter.ExportTypeMapping(mapping);
}
All types are mapped pretty good, except positiveInteger (from the namespace "http://www.w3.org/2001/XMLSchema").
I've tried to fix it from code, somthing like:
switch (mapping.XsdTypeName)
{
case "positiveInteger":
mapping.TypeFullName = "System.UInt32"; // was "System.String"
mapping.TypeName = "UInt32"; // was "String"
break;
default:
break;
}
but unfortunately all XmlTypeMapping properties are read only, so I can't event create a new instance to send to the function exporter.ExportTypeMapping().
I have no idea how to change the mapped type.