我正在尝试访问RDF中父类继承的属性。 我使用rdfs属性subClassOf定义了我的子类的实例。
使用乌龟语法:
ex:myClass1 a owl:class; rdfs:range xsd:integer. ex:myClass2 rdfs:subClassOf ex:myClass1. # defining instance of my class ex:instance1 ex:myClass1 1 . ex:instance2 ex:myClass2 2 .如果我想访问所有ex:myClass1和他的孩子的属性ex:property 。 我是否可以承认ex:myClass2是ex:myClass1并编写此SPARQL查询
SELECT ?instance ?value WHERE{ ?instance ex:myClass1 ?value . }获得我定义的两个值? 或者rdfs:subClassOf没有将子类定义为父类的更具体的版本?
I'm trying to access to the property inherited of a parent class in RDF. I define an instance of my child class using the rdfs property subClassOf.
With a turtle syntax :
ex:myClass1 a owl:class; rdfs:range xsd:integer. ex:myClass2 rdfs:subClassOf ex:myClass1. # defining instance of my class ex:instance1 ex:myClass1 1 . ex:instance2 ex:myClass2 2 .If I want to access to the property ex:property of all ex:myClass1 and his child. Can I admit that ex:myClass2 is a ex:myClass1 and write this SPARQL query
SELECT ?instance ?value WHERE{ ?instance ex:myClass1 ?value . }to obtain the two values I've defined? Or rdfs:subClassOf doesn't define a child class as a more specificaly version of the parent class?
最满意答案
为了补充Joshua试图解释的内容,您正在混合模式和数据概念。
我认为你应该定义的是(在简化的RDFS语法中):
ex:property rdfs:domain ex:myClass1 . ex:property rdfs:range xsd:integer . ex:myClass2 rdfs:subClassOf ex:myClass1. #this may be optional depending on the entailment regime your SPARQL enpoint uses ex:myClass1 a owl:class . # defining instance of my class ex:instance1 ex:property 1 . ex:instance2 ex:property 2 .然后你可以查询
SELECT ?instance ?value WHERE{ ?instance ex:property ?value . }根据SPARQL端点的蕴含制度,可以通过ex:属性推断出ex:instance1和ex:instance23至少是ex:Class1的实例(如果你想将其中一个作为ex:Class2,你将拥有添加三重ex:instance a ex:Class2到您的商店)
To complement what Joshua tried to explain you are mixing the schema and data concepts.
I think what you should define is (in simplified RDFS syntax):
ex:property rdfs:domain ex:myClass1 . ex:property rdfs:range xsd:integer . ex:myClass2 rdfs:subClassOf ex:myClass1. #this may be optional depending on the entailment regime your SPARQL enpoint uses ex:myClass1 a owl:class . # defining instance of my class ex:instance1 ex:property 1 . ex:instance2 ex:property 2 .then you can query
SELECT ?instance ?value WHERE{ ?instance ex:property ?value . }depending on the entailment regime of your SPARQL endpoint, it is inferred through the ex:property that ex:instance1 and ex:instance23 are at least instances of ex:Class1 (if you want to make one of those a ex:Class2 you will have to add the triple ex:instance a ex:Class2 to your store)
更多推荐
发布评论