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

Casting

From: Steve Harris <steve.harris@garlik.com>
Date: Mon, 16 Apr 2007 18:31:37 +0100
Message-Id: <B6708434-E699-4766-9575-EF108DEBB938@garlik.com>
To: dawg mailing list <public-rdf-dawg@w3.org>

Sorry, this is a bit late in the proceedings to be asking questions  
like this, but I've just hit something I don't follow.

I have a bunch of data that has latitude and longitude values encoded  
as plain literals, like:

[] :name "The Red Lion" ;
    :lat "-1.03" ;
    :long "51.2" .

Yes, I know that's not ideal, but such is life.

Now, if you want to FILTER on those values to narrow down, like:

SELECT ?name
WHERE {
   ?place :name ?name ;
          :lat ?lat ;
          :long ?long .
   FILTER(xsd:integer(?lat) = -1 && xsd:integer(?long) = 51)
}

it doesn't work. From my reading of http://www.w3.org/TR/xpath- 
functions/#casting-from-strings (which may well be flawed) it's an  
error to cast from "-1.03" to "-1"^^xsd:integer. I think you can do  
xsd:integer(xsd:double(?lat)) OK, but I don't think it will be  
obvious to many people why one is legal, and one is not. If that is  
the case.

I'd be interested to know what other people's implementations do.  
Obviously the "right" solution is to fix the data.

- Steve
Received on Monday, 16 April 2007 17:32:00 GMT

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