XML Enumeration

This should cover W3C XML Schema, Relax NG and DTD related problems.
rnrivas
Posts: 1
Joined: Mon Jan 26, 2009 9:11 pm

XML Enumeration

Post 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.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: XML Enumeration

Post 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
George Cristian Bina
Post Reply