W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2003

Possible XMLSchema for data value

From: Avin Patel <vze49rz3@verizon.net>
Date: Mon, 6 Jan 2003 18:19:46 -0500
Message-ID: <01a801c2b5da$1a596780$643a42d1@Avin>
To: "xmlschema" <xmlschema-dev@w3.org>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:35 GMT