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

Re: Possible XMLSchema for data value

From: Jeni Tennison <jeni@jenitennison.com>
Date: Tue, 7 Jan 2003 11:47:24 +0000
Message-ID: <1738198368.20030107114724@jenitennison.com>
To: "Avin Patel" <vze49rz3@verizon.net>
CC: "xmlschema" <xmlschema-dev@w3.org>

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 GMT

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