Specifying Values ​​in an Enumeration in XSD

I defined the enumeration as shown below in the XSD file

<xs:simpleType name="PaperSizes"> <xs:restriction base="xs:string"> <xs:enumeration value="NUMBERS"></xs:enumeration> <xs:enumeration value="PICTURE"></xs:enumeration> <xs:enumeration value="RTF"></xs:enumeration> </xs:restriction> 

I need to override the failure values ​​assigned by the compiler. i.e.: - for NUMBERS, the default value is 0. I need a value of 2 for it.

What changes do I need to make?

Thanks.

+4
source share
1 answer

You cannot set defaults for each of the values ​​in the collection. You can set one default value for any simple xsd type with the keyword "default".

So, if you want to set the default value in the above example, you can do something like:

 <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element default="PICTURE" name="PaperSizes"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="NUMBERS" /> <xs:enumeration value="PICTURE" /> <xs:enumeration value="RTF" /> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> 

Hope this helps.

+5
source

All Articles