Search code examples
sparqlowlontologyprotege

PROTÉGÉ SPARQL QUERY TAB: cannot query for ontology-specific classes


I am using SPARQL Query tab in Protege 5 to query an OWL ontology I have been constructing. I succeded in many kinds of queries, but when I use some specific class of my ontology inside the very same queries (that are apparently well formed) they return no results. Following, two of the problematic queries - assuming "Event" as one of the concepts of the ontology (http://www.semanticweb.org/ontologies/2014/5/MyOnto#Event):

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

SELECT ?a  WHERE { ?a rdfs:subClassOf onto:Event } 

and, with the same prefixes

SELECT ?a  WHERE { ?a rdfs:range onto:Event } 

Both return no results. However, if I substitute "onto:Event" for, let's say, ?b, both return a long list of results - inclunding Event as a match for ?b.

Is it something I'm misusing or forgetting (although I've seen this pattern in several links on internet with people claiming to have got results) or is it a limitation of SPARQL or some issue of the Protege tab?


Solution

  • The problem is that, in fact, although the URI of the ontology is:

    <http://www.semanticweb.org/ontologies/2014/5/MyOnto#>
    

    in the OWL document, the prefix used before class names is the IRI:

    <http://www.semanticweb.org/ontologies/2014/2/untitled-ontology-662#>
    

    Thus, replacing the old onto: by

    PREFIX onto: <http://www.semanticweb.org/ontologies/2014/2/untitled-ontology-662#> 
    

    solves the issue.

    (Thanks to @Csongor from Protégé Project mail list, who found the answer.)

    P.S.: It's also worthy to note that it can't be taken for granted that all the terms in the ontology will be <current_ontology_URI#term> - e.g. if one includes some terms in the ontology and then changes ontology URI, these terms will be identified as <previous_ontology_URI#term> and the new ones as <current_ontology_URI#term> (which was exactly the cause of the problem above).