1
I’m generating a class with XSD.EXE from a schema. I’m summarizing posting only the part of the schema that generates Enum that I doubt.
<xs:simpleType name="TCodUfIBGE">
<xs:annotation>
<xs:documentation>Tipo Código da UF da tabela do IBGE</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="11"/>
<xs:enumeration value="12"/>
<xs:enumeration value="13"/>
<xs:enumeration value="14"/>
<xs:enumeration value="15"/>
<xs:enumeration value="16"/>
<xs:enumeration value="17"/>
<xs:enumeration value="21"/>
<xs:enumeration value="22"/>
<xs:enumeration value="23"/>
<xs:enumeration value="24"/>
<xs:enumeration value="25"/>
<xs:enumeration value="26"/>
<xs:enumeration value="27"/>
<xs:enumeration value="28"/>
<xs:enumeration value="29"/>
<xs:enumeration value="31"/>
<xs:enumeration value="32"/>
<xs:enumeration value="33"/>
<xs:enumeration value="35"/>
<xs:enumeration value="41"/>
<xs:enumeration value="42"/>
<xs:enumeration value="43"/>
<xs:enumeration value="50"/>
<xs:enumeration value="51"/>
<xs:enumeration value="52"/>
<xs:enumeration value="53"/>
</xs:restriction>
</xs:simpleType>
In class it’s getting like this:
Note: Also summarized.
public enum TCodUfIBGE
{
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("11")]
Item11,
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("12")]
Item12,
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("13")]
Item13,
}
Example:
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("11")]
Item11 = 11,
Or else:
public enum TipoPessoa
{
[System.Xml.Serialization.XmlEnumAttribute("1")]
Fisica = 1,
[System.Xml.Serialization.XmlEnumAttribute("2")]
Juridica = 2
}
EDIT: Is there any way to generate this class with the values for the defined Enum items equal to those of the attribute?
Why in a real application it would be absurd ?
This is an exercise right? In a real application it would be absurd this kind of information stay in the code.
– Bacco
It is not for an application, I am doing several tricks with XSD.EXE to see how it works.
– Robss70
Ah good, if it is exercise/workout beauty. For a moment I found it kind of strange.
– Bacco
@Bacco, I’ll edit and add this question you commented.
– Robss70
Just in advance, in a real application if you leave an IBGE code table hardcoded on your system, you need to recompile the code every time you change something. If you query from DB, you can update at any time, and even have an interface to edit this data in DB.
– Bacco
@Bacco, got it. Thanks for your help.
– Robss70
Downloaded this schema from the
NFe
Correct?– rubStackOverflow
Yes, from the website itself, http://www.nfe.fazenda.gov.br/
– Robss70