XML Enumeration
Posted: Mon Jan 26, 2009 9:20 pm
When creating a type for a schema, such as
<xs:element name="test" type="xs:TestType" />
<xs:simpleType name="TestType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="Off"></xs:enumeration>
<xs:enumeration value="On"></xs:enumeration>
</xs:restriction>
</xs:simpleType>
Is it possible to have a set method that provides the ENUM ordinal. So in addition to having setTest("Off") and setTest("On") you could do setTest(0) for off and setTest(1) for On. I havent been able to find an example of this so I'm thinking its not currently possible. Any ideas?
When you use the get method, you can use TestTypes.Off_Type which would give you 0. But the set method doesnt have an int parameter option.
<xs:element name="test" type="xs:TestType" />
<xs:simpleType name="TestType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="Off"></xs:enumeration>
<xs:enumeration value="On"></xs:enumeration>
</xs:restriction>
</xs:simpleType>
Is it possible to have a set method that provides the ENUM ordinal. So in addition to having setTest("Off") and setTest("On") you could do setTest(0) for off and setTest(1) for On. I havent been able to find an example of this so I'm thinking its not currently possible. Any ideas?
When you use the get method, you can use TestTypes.Off_Type which would give you 0. But the set method doesnt have an int parameter option.