Re: Possible XMLSchema for data value

Hi All,
Actually I want to write following value:
<size><medium/></size>
or
<size><large/></size>
or
<size><small/></size>
or
<size>15</size>

So value would be integer value or empty elements: <large/>, <medium/>,
<small/>

Thank you,
Avin Patel


----- Original Message -----
From: "Bob Schloss" <rschloss@us.ibm.com>
To: "Avin Patel" <vze49rz3@verizon.net>
Sent: Monday, January 06, 2003 6:25 PM
Subject: Re: Possible XMLSchema for data value






How about....

<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:element name = "value" type="xsd:integer" />
   </xsd:choice>
</xsd:complexType>

Bob




                      "Avin Patel"
                      <vze49rz3@verizon        To:       "xmlschema"
<xmlschema-dev@w3.org>
                      .net>                    cc:
                      Sent by:                 Subject:  Possible XMLSchema
for data value
                      xmlschema-dev-req
                      uest@w3.org


                      01/06/2003 06:19
                      PM





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 Tuesday, 7 January 2003 09:38:32 UTC