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

Re: representing fixed point decimal types

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 1 May 2002 19:50:08 +0100
Message-ID: <50813561950.20020501195008@jenitennison.com>
To: "Cole, Russ E" <Russ.Cole@unisys.com>
CC: xmlschema-dev@w3.org
Hi Russ,

> Am I right that there are no fixed point types in xml schema? The
> closest thing I can find to precision/scale is
> totalDigits/fractionDigits. So, I find myself using
> minInclusive/maxInclusive. For example, for precision 8 scale 2:
> <xs:simpleType>
>               <xs:restriction base='xs:decimal'>
>                <xs:totalDigits value='8'/>
>                <xs:fractionDigits value='2'/>
>                <xs:minInclusive value='-999999.99'/>
>                <xs:maxInclusive value='999999.99'/>
>               </xs:restriction>
> </xs:simpleType>

Another method that you could use is to use a pattern to say that you
want exactly two decimal digits:

    <xs:restriction base="xs:decimal">
      <xs:totalDigits value="8" />
      <xs:fractionDigits value="2" />
      <xs:pattern value="-?\d{1,6}\.\d{2}" />

The pattern allows an optional minus sign, followed by between 1 and 6
digits, followed by a decimal point, followed by two digits.
> Also, the example in the xml schema standard seems wrong to me
> because it says using totalDigits 8 and fractionDigits 2 constrains
> the value to be less than 1 million whereas it only constrains the
> value to be less than 100 million.

I think that's already been noted. See



Jeni Tennison
Received on Wednesday, 1 May 2002 14:50:11 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:01 UTC