简体   繁体   中英

SPARQL/RDF query: selecting an instance from a class

I'm new to Sparql and need some help.

I have a class named "Learning_object" and a subclass named "General_characteristics" which has some properties (title, language and description).

I have given an instance named "Introduction_to_HTML" at "Learning_object" class. What i want to do is to select the "General_characteristics" for the "Introduction_to_HTML" instance.

I have done some research on google but haven't find a solution to this.

I can get all the instances of "Learning_object" using this:

SELECT ?entity
WHERE {
  ?entity rdf:type ?General_characteristics.
?General_characteristics rdfs:subClassOf* :Learning_object.
}

Thanks in advance! (sorry for my English)

Try something like this:

SELECT DISTINCT ?property
WHERE {
    ?entity rdf:type ?General_characteristics.
    ?General_characteristics rdfs:subClassOf* :Learning_object.
    ?entity ?property ?object.
    FILTER(?entity=<your_BASE_GRAPH_URI/Introduction_to_HTML>)
}

to retrieve a list of the property name available for your instance. If you also want the ?object value for each prperty, you should add the ?object binding in the SELECT DISTINCT... part. Please note if you have blank nodes you should find instead some "skolemized" value in ?object.

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