SPARQL query for "Tree of properties" ( inheritance predicates)

105 views Asked by At

This question was edited to remove an wrong example.

You can see a right way to store and query "subjects for inheritance predicates and inheritance objects" below. Based on UninformedUser advise.

example.ttl

@prefix rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:   <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl:    <http://www.w3.org/2002/07/owl#> .
@prefix uri:    <http://uri/> .

uri:Language            rdf:type                rdfs:Class .
uri:English             rdfs:subClassOf         uri:Language .
uri:BritishEnglish      rdfs:subClassOf         uri:English .
uri:Chinese             rdfs:subClassOf         uri:Language .
uri:MandarinChinese     rdfs:subClassOf         uri:Chinese .

uri:know                rdf:type                rdf:Property .
uri:write               rdfs:subPropertyOf      uri:know .
uri:speak               rdfs:subPropertyOf      uri:know .

uri:Alex                uri:speak               uri:English .
uri:John                uri:write               uri:BritishEnglish .
uri:Chen                uri:write               uri:Chinese .
uri:Lin                 uri:speak               uri:MandarinChinese .

sparql

select distinct * { ?p  rdfs:subPropertyOf*    uri:know     . 
                    ?s  ?p                     ?o           . 
                    ?o  rdfs:subClassOf*       uri:Language . }
s   p   o
http://uri/Alex     http://uri/speak    http://uri/English
http://uri/Lin      http://uri/speak    http://uri/MandarinChinese
http://uri/Chen     http://uri/write    http://uri/Chinese
http://uri/John     http://uri/write    http://uri/BritishEnglish
0

There are 0 answers