我试图理解 rdfs 域和范围的语义。因为我来自面向对象的背景,所以我很难理解语义以及如何根据 rdfs 语句验证数据。
这是一个海龟格式的示例文件:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix tmpl: <http://template.example.com/>
prefix data: <http://data.example.com/>
tmpl:Thing a owl:Class.
tmpl:Employment rdfs:subClassOf tmpl:TemporalThing.
tmpl:Party rdfs:subClassOf tmpl:Thing.
tmpl:Individual rdfs:subClassOf tmpl:Party.
tmpl:Organisation rdfs:subClassOf tmpl:Party.
tmpl:LimitedLiabilityCompany rdfs:subClassOf tmpl:Organisation.
tmpl:hasCurrentEmployer a owl:ObjectProperty;
rdfs:domain tmpl:Party;
rdfs:range tmpl:Party.
data:Simon a tmpl:Individual;
skos:prefLabel "Simon S".
data:PtyLtd a tmpl:LimitedLiabilityCompany.
data:Simon tmpl:hasCurrentEmployer data:PtyLtd.
tmpl:Animal a owl:Thing.
data:Beans a tmpl:Animal.
data:Simon tmpl:hasCurrentEmployer data:Beans.
我使用 GRAPHDB 作为我的测试环境。我希望最后一条语句会因某种消息而失败,因为“Beans”是“动物”,而不是“派对”。
然而,GRAPHDB 只是接受该声明。
有任何想法吗?
编辑
基于以下 Stanislav 的评论:虽然推理引擎可能对此没有问题,但我们可以在应用程序中使用域和范围进行错误检查。