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

I think my approach would be:

In 17.2, Casting to derived types, change "three cases" to "five cases"
(!) and add a fifth case (I'm not sure if its position in the sequence
matters):

   5. Casting to xs:integer or to a subtype of xs:integer
   This is done as if xs:integer were a primitive type. If the source
type is derived by restriction from the target type, then section 17.3
applies; otherwise if the source type is derived by restriction from
xs:integer, then section 17.4 applies; otherwise the special rules in
section 17.8.4 apply.

In 17.8.4, change the title to "Casting to xs:integer and its subtypes".
Add a paragraph at the end, saying: "If the target type is a subtype of
xs:integer, then TV is calculated as described above, and is then cast
to the target type by checking against the facets of the target type as
described in section 17.4."

Michael Kay


> -----Original Message-----
> From: public-qt-comments-request@w3.org 
> [mailto:public-qt-comments-request@w3.org] On Behalf Of Ashok Malhotra
> Sent: 09 January 2004 14:03
> To: Kay, Michael; public-qt-comments@w3.org
> Subject: 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:39:53 UTC