SPARQL Query - class and subclass give class name and namespace

How can I get all properties of a class and its subclass with properties from an RDF data source using a SPARQL query, given the class name and namespace?

+1


source to share


2 answers


How about this :

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?subClass ?predicate 
WHERE {
   ?subClass rdfs:subClassOf <http://dbpedia.org/ontology/Work> .
   ?predicate rdfs:domain ?subClass
}

      



Try a SPARQL tool like DBPedia SNORQL interface .

+3


source


Are you trying to execute a recursive SPARQL query? In other words, select a given person and all his properties. If the property object is another person, select its properties, etc.

I don't believe SPARQL supports this.

A naive approach would be to do something like this (and, assuming you mean people, not classes, this actually suits your requirements, but does not handle the next "level" of triplets).



CONSTRUCT {
    ?s ?p ?o .
    ?o ?p2 ?o2 .
} WHERE {
    ?s ?p ?o .
    ?o ?p2 ?o2 .
}

      

Note that if ?o2

is the subject of any operators, this query will not return them.

+3


source







All Articles