Re: extending enumeration ?

Hi Jeni,

is there also an ordering between the member types that are referenced and
the member types that are defined as anonymous inner types when deciding which
member type to use to create an instance?

I did not find a section in the spec. where an ordering of the member types
is mentioned.

Thanks,
--Stefan


> 
> Hi Evyatar,
> 
> > In schema with restriction of enumeration:
> >
> >                 <xsd:simpleType>
> >                         <xsd:restriction base="xsd:string">
> >                                 <xsd:enumeration value="High"/>
> >                                 <xsd:enumeration value="Medium"/>
> >                         </xsd:restriction>
> >                 </xsd:simpleType>
> >
> > If I want to state that the list is as specified but can also add
> > other values, is there a way to state that ?
> 
> You can use a union of the enumerated type and the more general string
> type. For example:
> 
> <xs:simpleType name="highOrMedium">
>   <xs:restriction base="xs:string">
>     <xs:enumeration value="High" />
>     <xs:enumeration value="Medium" />
>   </xs:restriction>
> </xs:simpleType>
> 
> <xs:simpleType name="possibleValues">
>   <xs:union memberTypes="highOrMedium xs:string" />
> </xs:simpleType>
> 
> Note that a value of the type possibleValues will always be valid
> (because every value is a valid string), which means that you won't be
> able to catch errors such as people using 'Med' instead of 'Medium'.
> 
> The only real benefit of using the union type is that if you were to
> use an application that gave you access to the type of the element or
> attribute then you would see the type 'highOrMedium' if someone had
> the value 'High' or 'Medium' and 'xs:string' at other times.
> 
> Also note that if you swapped 'highOrMedium' and 'xs:string' in the
> memberTypes attribute that this wouldn't occur -- a value is of the
> first type in a union type that it matches, so if they were swapped
> then every value would be labelled a string.
> 
> Cheers,
> 
> Jeni
> 
> ---
> Jeni Tennison
> http://www.jenitennison.com/
> 

Received on Monday, 26 August 2002 02:38:57 UTC