简体   繁体   中英

Protege: (SPARQL) Query Super class for individuals of Sub classes

Having a Super class Person which has two sub-classes Student and Staff . Student sub-class contains 3 individuals(name property): student1, student2 , student3. Staff Sub-class contains 2 individuals(name property): staff1 and staff2.

is it possible to query Person class and obtain all individuals as it is the super class?

How else can you go about this? especially when you have so many sub-classes?

Output similar to:

Person

-----------

student1

student2

student3

staff1

staff2

You need to ask for all resources that are members of either :Person or any of its sub-classes. If you use property path , you would need only one triple pattern in your query:

SELECT ?person
    WHERE { ?person a/rdfs:subClassOf*  :Person}

This query asks for resources that are members of the class :Person , which is the case when the star is zero, or are members of any of its subclasses, which is the case when the star is one and more.

If needed, you can further restrict the subject to be owl:NamedIndividual .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM