Enumeration Value Space Difference

Hello,

Is there a way to derive from a SimpleType in a way that the derived type allows only a proper subset of the value space of the base type?  This would be analogous to a set difference operation.  I can't use redefine, because I need to continue to use the larger value space of the original (base) type.

For example, if the base type were:

<xs:simpleType name="baseCodeType"> 
  <xs:restriction base="xs:string"> 
    <xs:enumeration value="A"/> 
    <xs:enumeration value="B"/> 
  </xs:restriction> 
</xs:simpleType>

How could I obtain a different type, that derived from "baseCodeType" but only allowed values of "A"?

In Spy, an element of the following derived type accepts values of "A" and "B".  Is this an error in Spy?  I searched the list archives and found that some of the experts believe(d) that the data types standard requires the following derived type to only accept the value "A".

<xs:simpleType name="derivedCodeType"> 
  <xs:restriction base="baseCodeType"> 
    <xs:enumeration value="A"/> 
  </xs:restriction> 
</xs:simpleType>

If the answer is, "No, this can't be done in W3C Schema", then can someone please explain why?   Why has not an xsd:difference element been defined, to go along with xsd:union?

Thanks,
Bill

Received on Thursday, 15 July 2004 13:49:43 UTC