Search code examples
sparqlrdfowlontologyprotege

SPARQL: Exclude datatype uri from query result


I am trying to learn SPARQL queries on Protege and I have added some individuals to query on the Movie ontology found at : Movie Ontology

I have following simple sparql query:

Query 1: Get all movies and actors having rating more than 7.0 

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX mov: <http://www.movieontology.org/2009/10/01/movieontology.owl#>

SELECT ?subject ?actors ?rating
    WHERE { 
        ?subject a mov:Movie;
             mov:hasActor ?actors;
            mov:imdbrating ?rating.
        Filter(?rating > "7.0"^^xsd:double)
     }

And I am getting the result as expected:

Result

The problem is that I dont need the ^^xsd:double uri in the rating column !! How do I get rid of the uri " ^^http://www.w3.org/2001/XMLSchema#double ". Thanks in advance !


Solution

  • Use str to get the lexical part

    SELECT ?subject ?actors (str(?rating) AS ?r)