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 15:08:15 +0000
Message-ID: <1733427218.20030107150815@jenitennison.com>
To: "Avin Patel" <vze49rz3@verizon.net>
CC: "xmlschema" <xmlschema-dev@w3.org>

Hi Avin,

> 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/>

That's impossible in W3C XML Schema unless you introduce xsi:type
attributes to indicate the kind of <size> element that's being used.
Would you be happy with:

  <size>medium</size> or
  <size>large</size> or
  <size>small</size> or
  <size>15</size>

This would be easy to do using a union type:

  <xs:element name="size">
    <xs:simpleType>
      <xs:union memberTypes="xs:integer">
        <xs:simpleType>
          <xs:enumeration value="large" />
          <xs:enumeration value="medium" />
          <xs:enumeration value="small" />
        </xs:simpleType>
      </xs:union>
    </xs:simpleType>
  </xs:element>
  
Cheers,

Jeni

P.S. It's simple in RELAX NG:

  <element name="size">
    <choice>
      <element name="medium">
        <empty />
      </element>
      <element name="large">
        <empty />
      </element>
      <element name="small">
        <empty />
      </element>
      <data type="integer" />
    </choice>
  </element>

---
Jeni Tennison
http://www.jenitennison.com/
Received on Tuesday, 7 January 2003 10:08:19 GMT

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