Re: casting literal values

Julian Reschke wrote:
>
> Javier Godoy wrote:
>
>>
>> What happens if the property value can not be cast to the specified
>> datatype?:
>> - when casting a literal value (DAV:literal) if the property type is
>> known and the server chooses to treat the literal according to this type,
>> - when casting typed literal values.
>>

Excuse me, I should have written "literal" instead of "property". So my
question is: what happens if the *literal* can not be cast to the specified
datatype?:

> if the DAV:typed-value specified in the query can not be converted to the
> desired type, it probably would be good to reject the query,

I agree. Should this behaviour be RECOMMENDED?

> as in
> <lt xmlns="DAV:"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xmlns:xs="http://www.w3.org/2001/XMLSchema">
>   <prop><edits xmlns="http://ns.example.org"/></prop>
>   <typed-literal xsi:type="xs:integer">foobar</typed-literal>
> </lt>
>
> Did you mean that case?

Yes, and about DAV:literal too, because Section 5.10 says [[
  when operand for a comparison with a property for which the type is known,
it MAY be treated according to this type
]]

Suppose the type of the "edits" property is xs:integer.
If the server ignores its type, the following expression is valid, and it
evaluates to false because  "foobar" may not be a value of e:edits, if the
comparison is performed as if the property were xs:string (default
behaviour).

<eq xmlns="DAV:" xmlns:e="http://ns.example.org">
   <prop><e:edits/></prop>
   <literal>foobar</literal>
</eq>

On the other hand, if the server knows e:edits is xs:integer, and it cast
the literal as xs:integer, the expression will not be not valid and there
will be a casting error (as in the typed-literal example above).

Note that
 <typed-literal xsi:type="xs:integer">foobar</typed-literal>
is likely a client's fault (e.g., it did not validate the literal against
the specified datatype)

In the DAV:literal case, whether the error is a fatal one or it is silently
ignored, depends on how the server handles DAV:literal for that property.
My point of view is that, since the client would have used DAV:typed-literal
if it wanted to force casting, the server MAY invalidate the query, or it
MAY fail as in the typed-literal case...

Does this make sense?


Best Regards,

Javier

Received on Friday, 15 February 2008 10:30:16 UTC