Re: math ops and datatypes

On 25/04/11 10:26, Andy Seaborne wrote:
>
>
> On 25/04/11 05:45, Lee Feigenbaum wrote:
>> Could someone take a moment and walk me through the relevant spec text
>> that tells me what the result of the following should be?
>>
>> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>> SELECT (datatype("1"^^xsd:int + "1"^^xsd:int) AS ?datatype)
>> {}
>>
>>
>> Lee
>>
>
> Alegbra:
> (project (?datatype)
> (extend ((?datatype (datatype (+ "1"^^xsd:int "1"^^xsd:int))))
> empty BGP)))
>
>
> empty BGP:
> {} => One row, no columns.
>
> extend:
>
> Evaluate the expression from the inside:
>
> "1"^^xsd:int + "1"^^xsd:int
>
> http://www.w3.org/TR/rdf-sparql-query/#OperatorMapping
>
> numeric numeric => op:numeric-add(A, B)
>
> http://www.w3.org/TR/xpath-functions/#op.numeric
> op:operation(xs:integer, xs:integer)
>
> is the closest operation so promote xsd:int to xsd:integer:
> "1"^^xsd:int => "1"^^xsd:integer

"closest" is a bit vague:

http://www.w3.org/TR/xpath20/#promotion
"""
the first type in the ordered list (xs:integer, xs:decimal, xs:float, 
xs:double)
"""
hence integer, not decimal.

>
> then op:numeric-add
> "2"^^xsd:integer
>
> datatype("2"^^xsd:integer) ==> xsd:integer
>
> AS ?datatype
> ==>
> New column ?datatype
> Value: xsd:integer
>
> Andy
>

Received on Monday, 25 April 2011 11:49:10 UTC