XML Enumeration

This should cover W3C XML Schema, Relax NG and DTD related problems.
rnrivas
Posts: 1

XML Enumeration

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.
george
Site Admin
Posts: 2100

Re: XML Enumeration

Wed Jan 28, 2009 2:01 pm

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

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 0 guests