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

Re: SPARQL cast tests

From: Seaborne, Andy <andy.seaborne@hp.com>
Date: Mon, 10 Apr 2006 12:22:46 +0100
Message-ID: <443A4006.7060006@hp.com>
To: Steve Harris <steve.harris@richmondinformatics.com>
CC: RDF Data Access Working Group <public-rdf-dawg@w3.org>



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.

> 
> 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.

> 
> 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/>?

> 
> - Steve
> 

	Andy
Received on Monday, 10 April 2006 11:23:03 GMT

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