You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Schmid, David" <sc...@cajvc.com> on 2002/02/26 20:38:24 UTC

Validation problem with restricted doubles/floats with minInclusi ve of 0

Hello

I am having a problem putting range restrictions on elements of types
xsd:double and xsd:float when minInclusive is 0.
 E.g. if my schema is :

<xsd:element name="left" default="0">
 <xsd:simpleType>
  <xsd:restriction base="xsd:double">
   <xsd:minInclusive value="0.0"/>
   <xsd:maxInclusive value="1.0"/>
  </xsd:restriction>
 </xsd:simpleType>
</xsd:element>

and I parse an instance doc containing:
        <left>0.000000</left>

I get an error:

Datatype error: Type:InvalidDatatypeFacetException, Message:Value '+0E+0'
must be greater than or equal to MinInclusive '0.0'

I think this problem is related to the representation of 0 in the schema. If
I set a minInclusive to -0.000000001 or something I can get close to the
correct behavior, but 0, 0.0, 0.00, +0E+0, etc all fail. This does not fail
if I use xsd:decimal instead of xsd:double or xsd:float.

Am I misusing this somehow or is this a bug?

Thanks!




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Validation problem with restricted doubles/floats with minInclusive of 0

Posted by PeiYong PY Zhang <pe...@ca.ibm.com>.
Hi, there,

    If you run your sample against the latest nightly build, you may have a
different
error message which reads:

    Message: Datatype error: type:InvalidDatatypeFacetException,
    Message: Value '0.00000' shall be in the range of '-1.401298...E-45',
                    '+1.401298...E-45'.

    Basically, only the '-0', '+0' and '0.0' (exactly) are valid representation
for negative zero,
positive zero, and neural zero (which is not **EXPLICITYLY** stated in the
Specs),
for double and float.

    Any other representation, with and only with extra 0s following the '0.0' is
NOT treated
as the same as '0.0', and therefore they are INvalid since they are within the
unrepresentable
range, (-1.401298..E-45, 0] and [0, +1.401298...E-45).

Rgds,
PeiYong

"Schmid, David" wrote:

> Hello
>
> I am having a problem putting range restrictions on elements of types
> xsd:double and xsd:float when minInclusive is 0.
>  E.g. if my schema is :
>
> <xsd:element name="left" default="0">
>  <xsd:simpleType>
>   <xsd:restriction base="xsd:double">
>    <xsd:minInclusive value="0.0"/>
>    <xsd:maxInclusive value="1.0"/>
>   </xsd:restriction>
>  </xsd:simpleType>
> </xsd:element>
>
> and I parse an instance doc containing:
>         <left>0.000000</left>
>
> I get an error:
>
> Datatype error: Type:InvalidDatatypeFacetException, Message:Value '+0E+0'
> must be greater than or equal to MinInclusive '0.0'
>
> I think this problem is related to the representation of 0 in the schema. If
> I set a minInclusive to -0.000000001 or something I can get close to the
> correct behavior, but 0, 0.0, 0.00, +0E+0, etc all fail. This does not fail
> if I use xsd:decimal instead of xsd:double or xsd:float.
>
> Am I misusing this somehow or is this a bug?
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org