简体   繁体   English

SPARQL / RDF查询:从类中选择一个实例

[英]SPARQL/RDF query: selecting an instance from a class

I'm new to Sparql and need some help. 我是Sparql的新手,需要帮助。

I have a class named "Learning_object" and a subclass named "General_characteristics" which has some properties (title, language and description). 我有一个名为“ Learning_object”的类和一个名为“ General_characteristics”的子类,它具有一些属性(标题,语言和描述)。

I have given an instance named "Introduction_to_HTML" at "Learning_object" class. 我在“ Learning_object”类中给出了一个名为“ Introduction_to_HTML”的实例。 What i want to do is to select the "General_characteristics" for the "Introduction_to_HTML" instance. 我想做的是为“ Introduction_to_HTML”实例选择“ General_characteristics”。

I have done some research on google but haven't find a solution to this. 我在Google上做了一些研究,但没有找到解决方案。

I can get all the instances of "Learning_object" using this: 我可以使用以下方法获取“ Learning_object”的所有实例:

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. 如果还需要每个属性的?object值,则应在SELECT DISTINCT ...部分中添加?object绑定。 Please note if you have blank nodes you should find instead some "skolemized" value in ?object. 请注意,如果您有空白节点,则应在?object中找到一些“ skolemized”值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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