Re: SPARQL cast tests

On 10 Apr 2006, at 12:22, Seaborne, Andy wrote:

>
>
> Steve Harris wrote:
>> I've been implementing the casts in SPARQL (again), and I think  
>> there  a need for more tests in this area, for example:
>> data:
>> :a :p "12.3"^^xsd:integer .
>> :b :p "12.3" .
>> query:
>> SELECT ?x
>> WHERE { ?x ?y ?z . FILTER(?z) = 12.3) }
>> from my reading of the spec that will return ?x = :a and :b,  
>> which  might surprise anyone who's not familiar with the way RDF  
>> doesn't  handle numbers.
>
> ARQ issues a warning on "12.3"^^xsd:integer  because, while a legal  
> RDF term, it can't be cast.  So it is an RDF term but not an  
> integer value and hence the comparison falls back to comparing RDF  
> terms and is false (different datatypes).  So it gets  
> "12.3"^^xsd:integer is not equal to 12.3 decimal.

Right, that's the difference, my engine doesn't complain about the  
data. It treats it as "12"^^xsd:integer for the purposes of sparql  
filter expressions. If there's a spec. that says not to do that I'll  
follow it.

>> Also,
>> FILTER(xsd:decimal(xsd:integer(?z)) = 12.3)
>> for which I can't work out what the correct answer is, as it  
>> seems  unlikely that "12.3" is a valid lexical value for an  
>> xsd:integer, but  it's a bit odd if that gives a different result  
>> to the other test.
>
> I get a cast exception from xsd:integer("12.3"^^xsd:integer) as  
> "12.3" is not a valid lexical form and (this time) a plain RDF term  
> is not acceptable as the result of the cast.

I get the same for that one.

>> Also, and I'm sure I've asked this before, but 11.5 seems to  
>> indicate  that its legal to cast an IRI to an xsd:string without  
>> mentioning STR (), which is not how I remembered that part of the  
>> design.
>
> The cast "xs:anyURI => xs:string" is allowed by xpath-functions
>
> http://www.w3.org/TR/xpath-functions/#casting-from-primitive-to- 
> primitive
>
> But (11.1)
> """
> IRI (corresponds to the Concepts and Abstract Syntax term "RDF URI  
> reference")
> """
> so isn't "http://example/"^^xs:anyURI is different from <http:// 
> example/>?

Sure, but 11.5 says:

bool = xsd:boolean
dbl = xsd:double
flt = xsd:float
dec = xsd:decimal
int = xsd:integer
dT = xsd:dateTime
str = xsd:string
IRI = IRI
ltrl = simple literal

Then in the IRI/String column it has a Y, so either IRI in 11.5  
should be xsd:anyURI, or that should be an N. I think.

- Steve

Received on Monday, 10 April 2006 13:19:38 UTC