- From: Cole, Russ E <Russ.Cole@unisys.com>
- Date: Wed, 1 May 2002 15:02:02 -0500
- To: Jeni Tennison <jeni@jenitennison.com>
- Cc: xmlschema-dev@w3.org
Thanks for the information, Jeni.
Does anyone know the rationale for the design of totalDigits/fractionDigits?
What problem do they solve without having to use some sort of 'restriction'?
I had assumed (probably because of the incorrect example) that the decimal
type would have been designed so that fixed point numbers could have been
defined simply. I'm just curious; it's not important.
Russ Cole
-----Original Message-----
From: Jeni Tennison [mailto:jeni@jenitennison.com]
Sent: Wednesday, May 01, 2002 11:50 AM
To: Cole, Russ E
Cc: xmlschema-dev@w3.org
Subject: Re: representing fixed point decimal types
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:simpleType>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="8" />
<xs:fractionDigits value="2" />
<xs:pattern value="-?\d{1,6}\.\d{2}" />
</xs:restriction>
</xs:simpleType>
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
http://www.w3.org/2001/05/xmlschema-rec-comments#pfiTotalDigits
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 1 May 2002 16:02:19 UTC