Tuesday, October 27, 2015

make an enum in an XSD?

I think it goes something like this:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="Whatever">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="Name" type="xs:string" />
            <xs:element name="Animal" type="WhateverAnimal" />
            <xs:element name="Age" type="xs:integer" />
            <xs:element name="Price" type="xs:decimal" />
         </xs:sequence>
      </xs:complexType>
   </xs:element>
   <xs:simpleType name="WhateverAnimal">
      <xs:restriction base="xs:string">
         <xs:enumeration value="bat" />
         <xs:enumeration value="cat" />
         <xs:enumeration value="rat" />
      </xs:restriction>
   </xs:simpleType>
</xs:schema>

 
 

I got the idea from this.

No comments:

Post a Comment