I have an XML schema that uses enumerations, but when I look at the generated XML object in Delphi, the enumeration restriction has been dropped. Is there any way to get Delphi to generate the enum and build it into the object?
XSD Snippet:
<xs:simpleType name="enumType" final="restriction">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="Each"/>
<xs:enumeration value="Units"/>
<xs:enumeration value="Area"/>
<xs:enumeration value="Payroll"/>
<xs:enumeration value="Sales"/>
<xs:enumeration value="TotalCost"/>
<xs:enumeration value="Other"/>
</xs:restriction>
</xs:simpleType>
What I would expect to see in Delphi is a field that accepts a enum that is then converted to it’s corresponing string when the XML is generated, but that field is just an ordinary string.
What you can do is create your own enumerated type with the same string constants as names and use the unit TypInfo with the function GetEnumValue and GetEnumString.
This allows you to prefix the names with a few lowercase letters like in other Delphi code: