Search code examples
sparqlontologyfuseki

Querying subclasses through Fuseki


I use the following simple SPARQL query to obtain a list of classes of an ontology and their subclasses through Fuseki:

SELECT DISTINCT ?subject ?object
WHERE { ?subject rdfs:subClassOf ?object }

This way, I can see the complete URI of all the classes. Now, I would like to query the subclasses of a specific class, say abc

I look at the output of the query and I see the URI of the class in focus abc is this:

http://blahblahblah/file.owl#abc

So, I pose the following SPARQL query to get its subclasses:

SELECT DISTINCT ?subject
WHERE { ?subject rdfs:subClassOf http://blahblahblah/file.owl#abc }

But the output is empty. I also trying enclosing the URL within single quote and double quotes, to no avail.

SELECT DISTINCT ?subject
WHERE { ?subject rdfs:subClassOf 'http://blahblahblah/file.owl#abc' }

SELECT DISTINCT ?subject
WHERE { ?subject rdfs:subClassOf "http://blahblahblah/file.owl#abc" }

What am I doing wrong?

Thanks,


Solution

  • The syntax for IRIs in SPARQL encloses IRIs in angle brackets (< and >). Your query should be written as:

    SELECT DISTINCT ?subject
    WHERE { ?subject rdfs:subClassOf <http://blahblahblah/file.owl#abc> }