W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > April to June 2011

Re: math ops and datatypes

From: Andy Seaborne <andy.seaborne@epimorphics.com>
Date: Mon, 25 Apr 2011 12:48:44 +0100
Message-ID: <4DB55F9C.6050401@epimorphics.com>
To: public-rdf-dawg@w3.org


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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:46 GMT