W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2002

Re: Clarification on enumerations

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 19 Jun 2002 11:09:35 +0100
Message-ID: <112-1633961603.20020619110935@jenitennison.com>
To: "Michael Leditschke" <mike@ammd.com.au>
CC: xmlschema-dev@w3.org

Hi Michael,

> If I read the datatypes spec correctly, the following definition
> <xs:simpleType name="AFewNumbers>
>   <xs:restriction base="xs:decimal">
>     <xs:enumeration value="1.2"/>
>     <xs:enumeration value="5.5"/>
>   </xs:restriction>
> </xs:simpleType>
> would not prevent lexical representations such as +00001.2 and
> 5.5000000000 appearing in instances and being declared valid by the
> schema. Is this correct?


> I'm assuming it is because enumerations operate on the value space,
> and 1.2 and 5.5 each have an infinite set of equivalent lexical
> representations.


If you want to restrict the lexical representation, use a pattern as
well (or instead, but as well is better because it enables other
applications to get access to the enumerated values without having to
have a fairly sophisticated regular expression parser):

<xs:simpleType name="AFewNumbers">
  <xs:restriction base="xs:decimal">
    <xs:enumeration value="1.2" />
    <xs:enumeration value="5.5" />
    <xs:pattern value="1\.2" />
    <xs:pattern value="5\.5" />



Jeni Tennison
Received on Wednesday, 19 June 2002 06:09:37 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:57 UTC