XML Datatype clarification: fractionDigits

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

XML Datatype clarification: fractionDigits

Nochum Klein
I was hoping to get some clarification regarding the use of  <xsd:fractionDigits value="0"/>.  My understanding of the specification is that there must be at most the number of specified digits. Therefore if it's zero then there MUST be zero digits (and "1..0" should be represented as "1").  Where the fractionDigits is set to zero, the resulting value can only be supported in a lexical representation of the "xsd:decimal" data type (e.g. 1), but not the canonical one (which requires 1.0).  I understand that the spec addresses this with lexical-canonical mappings.  However assume that a WSDL contains a restriction for zero fractionDigits.  If a value of "1.0" is input, should the input be rejected as it is incompatible with the restriction, or should it be accepted since there is a valid mapping to a canonical representation that would be compatible with the restriction?

Most grateful for your insights on this.

Sincerely,

Nochum Klein
Reply | Threaded
Open this post in threaded view
|

Re: XML Datatype clarification: fractionDigits

Mukul Gandhi
On Fri, Jun 21, 2013 at 11:35 PM, Nochum Klein <[hidden email]> wrote:
> I was hoping to get some clarification regarding the use of
> <xsd:fractionDigits value="0"/>.

I think, doing this on xsd:decimal is perhaps equivalent to using xsd:integer.

> My understanding of the specification is that there must be at most the number of specified digits.

I agree. Thats what I can understand from spec also.

> Therefore if it's zero then there MUST be zero digits (and "1..0" should be represented as
> "1").  Where the fractionDigits is set to zero, the resulting value can only
> be supported in a lexical representation of the "xsd:decimal" data type
> (e.g. 1), but not the canonical one (which requires 1.0).  I understand that
> the spec addresses this with lexical-canonical mappings.  However assume
> that a WSDL contains a restriction for zero fractionDigits.  If a value of
> "1.0" is input, should the input be rejected as it is incompatible with the
> restriction, or should it be accepted since there is a valid mapping to a
> canonical representation that would be compatible with the restriction?

The spec of xsd:fractionDigits says, "it does not restrict the
·lexical space· directly; a lexical representation that adds
non-significant leading or trailing zero digits is still permitted.".
My reading of this says, if an input value is 1.0 and
xsd:fractionDigits value="0" then this value would be reported as
valid, since in this case trailing zero was removed and than
validation was done.



--
Regards,
Mukul Gandhi

Reply | Threaded
Open this post in threaded view
|

Re: XML Datatype clarification: fractionDigits

Michael Kay
Yes. 4.3.12 says

[Definition:]   fractionDigits controls the size of the minimum difference between values in the ·value space· of datatypes ·derived· from decimal, by restricting the ·value space· to numbers that are expressible as i × 10^-n where i and n are integers and 0 <= n <= fractionDigits.

so setting fractionDigits restricts the value space to integer multiples of 1x10^0, i.e. to whole numbers. The value 12 can still be written as 12.0. This is not the same as xs:integer, because xs:integer also restricts the lexical space.

Michael Kay
Saxonica

On 25 Jun 2013, at 15:45, Mukul Gandhi wrote:

> On Fri, Jun 21, 2013 at 11:35 PM, Nochum Klein <[hidden email]> wrote:
>> I was hoping to get some clarification regarding the use of
>> <xsd:fractionDigits value="0"/>.
>
> I think, doing this on xsd:decimal is perhaps equivalent to using xsd:integer.
>
>> My understanding of the specification is that there must be at most the number of specified digits.
>
> I agree. Thats what I can understand from spec also.
>
>> Therefore if it's zero then there MUST be zero digits (and "1..0" should be represented as
>> "1").  Where the fractionDigits is set to zero, the resulting value can only
>> be supported in a lexical representation of the "xsd:decimal" data type
>> (e.g. 1), but not the canonical one (which requires 1.0).  I understand that
>> the spec addresses this with lexical-canonical mappings.  However assume
>> that a WSDL contains a restriction for zero fractionDigits.  If a value of
>> "1.0" is input, should the input be rejected as it is incompatible with the
>> restriction, or should it be accepted since there is a valid mapping to a
>> canonical representation that would be compatible with the restriction?
>
> The spec of xsd:fractionDigits says, "it does not restrict the
> ·lexical space· directly; a lexical representation that adds
> non-significant leading or trailing zero digits is still permitted.".
> My reading of this says, if an input value is 1.0 and
> xsd:fractionDigits value="0" then this value would be reported as
> valid, since in this case trailing zero was removed and than
> validation was done.
>
>
>
> --
> Regards,
> Mukul Gandhi
>


Reply | Threaded
Open this post in threaded view
|

Re: XML Datatype clarification: fractionDigits

Mukul Gandhi
On Tue, Jun 25, 2013 at 8:45 PM, Michael Kay <[hidden email]> wrote:
> The value 12 can still be written as 12.0. This is not the same as xs:integer, because xs:integer also restricts the lexical space.

Thanks for pointing this. I meant that when we're using
<xs:fractionDigits value="0"/> on a xs:decimal, we're effectively
using no precision to the value (a nature of xs:integer).

But your point is more correct.



--
Regards,
Mukul Gandhi