Page 1 of 1

XML Enumeration

Posted: Mon Jan 26, 2009 9:20 pm
by rnrivas
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.

Re: XML Enumeration

Posted: Wed Jan 28, 2009 2:01 pm
by george
Hi,

I do not understand the context of your question so I am afraid I cannot help you much with your question. One thing that looks trange however is this
<xs:element name="test" type="xs:TestType" />

<xs:simpleType name="TestType">
You refer to the TestType using the xs prefix which is bound to the XML Schema namespace. You nee to use a prefix corresponding to your schema target namespace or if your schema has no target namespace defined then you should not use any prefix and there should be no default namespace declaration.

Regards,
George