RE: [F+O] Casting to subtypes of xs:integer

At the 1/6 telcon I took an action to suggest wording to clarify the
situation.  I've been thinking about what wording to add. Here are some
thoughts.

In making the cast xs:short(4.3), section 17.4, "Casting within a branch
of the hierarchy" applies.  This says that the facets of the target type
should be checked.  Since xs:short is, eventually, derived from
xs:decimal the section suggests that the cast can be done directly
without an intermediate cast to integer.  Read this way the rules of
17.8.4 are bypassed and truncation does not occur.  This is the problem
Mike points out.

SUGGESTION 1:
Add wording to 17.4 saying that the casting must be done and the facets
checked at each step of the derivation chain.  This would make it clear
that the casting in the above example would go from decimal to integer
to short.
Rules in 18.8.4 would apply at the first step.

SUGGESTION 2:
Add the words between the stars to the following sentence:
"See 17.8.4 Casting to xs:integer for rules regarding casting to
xs:integer *and its subtypes*."

SUGGESTION 3:
XPath treats xs:integer as a primitive numeric type.  The casting
section provides rules for casting to/from integer to other primitive
types.  However, section 17.1 "Casting from primitive type to primitive
type" does not say that xs:integer should be treated as a primitive
type.  We could add wording to that effect.

Please comment.  My preference is for suggestions 1 and 3.

All the best, Ashok

-----Original Message-----
From: public-qt-comments-request@w3.org
[mailto:public-qt-comments-request@w3.org] On Behalf Of Kay, Michael
Sent: Wednesday, December 10, 2003 5:19 AM
To: public-qt-comments@w3.org
Subject: [F+O] Casting to subtypes of xs:integer


The normal rules for casting to a derived type are that the value must
satisfy all the facets of the target type. But there are special rules
in
section 17.8.4 for xs:integer, which cause the supplied value to be
truncated towards zero.

It's not clear whether or not these special rules also apply if the
target
type is a subtype of xs:integer. For example, xs:short(4.3). 

I think they should apply. But the rules then need to be modified to
allow
this. For example, the clause "and TV is xs:integer(IV)" is wrong.

Michael Kay

PS: these rules still have references to xs:anySimpleType. This doesn't
belong in the casting rules because it's not an atomic type. It's gone
from
the table, but not from the text.

Received on Friday, 9 January 2004 09:02:31 UTC