Canonical forms for literals in SQL vs XSD

There was discussion today about ISSUE-69 and the datatype mapping. One question was whether canonicalization, if at all, should be performed according to the SQL spec or according to the XSD spec. (By “canonical SQL” I mean the result of “CAST(xxx AS VARCHAR)”, which is the closest SQL gets to having canonical forms.)

I did a quick reading of the specs to identify cases where both have different canonical forms. I'm not 100% confident that I covered everything. But to the best of my knowledge, the mapping we have in R2RML produces non-canonical XSD literals in the following cases:


Any decimal numbers with fraction part equal 0
Canonical SQL: "42"^^xsd:decimal
Canonical XSD: "42.0"^^xsd:decimal
(in XSD 1.1, XSD canonical is changed to be the same as SQL)

Any decimal numbers with integer part equal 0
Canonical SQL: ".5"^^xsd:decimal
Canonical XSD: "0.5"^^xsd:decimal

Floating point number 0
Canonical SQL: "0E0"^^xsd:double
Canonical XSD: "0.0E0"^^xsd:double

Any time and datetime value with time zone, e.g., noon India standard time
Canonical SQL: "12:00:00+5:30"^^xsd:time
Canonical XSD: "17:30:00Z"^^xsd:time


Best,
Richard

Received on Tuesday, 15 November 2011 19:59:22 UTC