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/27 21:14:58 UTC
Re: Validation problem with restricted doubles/floats with minInc
lusive
Hi PeiYong
Thanks for the info!
I understand that the Specs don't demand it in any way, but, honestly,
everyone knows that 0.00 and 0.00000 and 0.000000 are all valid
representations
of zero, and zero is always a valid float/double. Can't the validator be
made
smart enough to understand this too? IMHO this would get rid of a nasty
'gotcha' and make Xerces that much easier to use.
Otherwise I'll be forced to insert logic in my XML-writing code to treat
zero values as a special case and be sure it writes '0.0'. This is do-able,
but it just doesn't seem right that I should have to.
-Dave
> 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