Possible XMLSchema for data value

Hi All,
How can I write the XML Schema definition for following data value:
value1:
<size>
    <medium/>
</size>

value2:
<size>
    <value>15</value>
</size>

One possible way I can think about is:
<xsd:element name = "Size" type="SizeType">
<xsd:complexType name ="SizeType">
    <xsd:union memberTypes="xsd:integer">
    <xsd:simpleType>
       <xsd:restriction base="xsd:token">
          <xsd:enumeration value =  "&lt;midium/&gt;"/>
          <xsd:enumeration value =  "&lt;large/&gt;"/>
          <xsd:enumeration value =  "&lt;small/&gt;"/>
       </xsd:restriction>
    </xsd:simpleType>
 </xsd:simpleType>

But SAX validators considers value1:<size><medium/></size>, medium as "element" of size "element", not as "value". I can write in another way as:

<xsd:element name = "Size" type="SizeType">
<xsd:complexType name ="SizeType">
   <xsd:choice>
        <xsd:element name = "small" type="xsd:integer" default="0" />
        <xsd:element name = "large" type="xsd:integer" default="1" />
        <xsd:element name = "medium" type="xsd:integer" default="2" />
   </xsd:choice>
</xsd:complexType>

But I am not able mix this definition with integer value definition.
complexType mix mode can work for this case, but it is mostly not
supported by many XML parser. So I can't use mix mode.

Please provide any suggestion.

Thank you
Avin Patel

Received on Monday, 6 January 2003 18:20:08 UTC