SPARQL in Protege 4.3

373 views Asked by At

I need to return individuals for my query:

SELECT ?subject ?class
            WHERE { ?subject rdfs:subClassOf ?class. 
?class rdfs:comment "linear"@en}

But it works only with subclasses. Should I replace rdfs:subClassOf on different operator?

2

There are 2 answers

0
Joshua Taylor On BEST ANSWER

Your query specifically asks for ?subjects that are subclasses of ?class (where ?class has the rdfs:comment "linear"@en). To retrieve instances of type ?class, you'd use

?subject rdf:type ?class

or, since SPARQL allows abbreviating rdf:type by a,

?subject a ?class
0
Abecee On

If you can't share details about the body of data, you are querying, you might want to get an idea yourself by checking

SELECT ?s ?p ?subject ?class
WHERE
{ ?s ?p ?class . 
  ?subject rdfs:subClassOf ?class . 
  ?class rdfs:comment "linear"@en .
} ORDER BY ?s ?p ?subject ?class

and/or

SELECT ?subject ?class ?p ?o
WHERE
{ ?subject ?p ?o .
  ?subject rdfs:subClassOf ?class . 
  ?class rdfs:comment "linear"@en .
} ORDER BY ?subject ?class ?p ?o

from where you can expand in the same manner until you get a handle.