Re: Possible XMLSchema for data value

Hi Avin,

> How can I write the XML Schema definition for following data value:
> value1:
> <size>
>     <medium/>
> </size>
>
> value2:
> <size>
>     <value>15</value>
> </size>

It looks as though you want the <size> element to either hold an empty
<medium>, <large>, or <small> element or hold a <value> element with
an integer value. In that case, you need something along the lines of:

<xs:element name="size">
  <xs:complexType>
    <xs:choice>
      <xs:element name="large" type="empty" />
      <xs:element name="medium" type="empty" />
      <xs:element name="small" type="empty" />
      <xs:element name="value" type="xs:integer" />
    </xs:choice>
  </xs:complexType>
</xs:element>

<xs:complexType name="empty">
  <xs:restriction />
</xs:complexType>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Tuesday, 7 January 2003 06:47:41 UTC