Re: Possible XMLSchema for data value

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 UTC