Warm tip: This article is reproduced from serverfault.com, please click

其他-rdfs:subPropertyOf 的 Shacl 处理

(其他 - Shacl handling of rdfs:subPropertyOf)

发布于 2021-06-21 17:22:32

我有以下 shacl 规范

efdn:Relation
  rdf:type owl:Class ;
  rdf:type sh:NodeShape ;
  rdfs:label "Relation"@en ;
  sh:property [
    sh:path efdn:nondirectionalLinkWith ;
    sh:NodeKind sh:IRI ;
    sh:maxCount 2 ;
    sh:minCount 2 ;
  ] ;
.

我的目标是表达一个关系必须完全由“nondirectionalLinkWith”对象属性连接。更具体地说,我想表示它可以是"nondirectionalLinkWith"的任何 subPropertyOf 。换句话说,可以说,一个 Relation 对象是这样的,它必须由 2 个非定向链接连接。其中非定向链接是作为 subPropertyOf "nondirectionalLinkWith"的任何对象属性。

1 ) 我想知道如何使用 shacl 来表达这一点。

到目前为止,我看到的唯一可能性是显式使用 RDFS Reasoner。也就是说,虽然 Shacl 优雅地处理 rdfs:subClassOf,因此不需要使用 RDFS Reasoner,但 rdfs:SubPropertyOf 似乎没有支持。

我在这里是否正确,或者有一种方法可以直接在 shacl 中表达这种约束。

使用 RDFS 推理器,我们有:

Construct {
  :x1 :p1 :x2
} Where {
  :x1 :p2. :x2
  :p2 rdfs:subPropertyOf :p1. 
}

这允许然后验证关系。但是,我想知道我是否可以完全避免使用 RDFS Reasoner 来处理这样一个简单的案例?如果它可以以某种方式以纯 shacl 表示,或者任何其他解决方法将不胜感激。

Questioner
MaatDeamon
Viewed
0
Holger Knublauch 2021-06-23 06:04:12

首先,注意约束属性 sh:nodeKind 必须以小写 n 开头

SHACL 不直接支持 rdfs:subPropertyOf,所以你说得对,要求 RDFS 推理是一种方法。你可以为此目的使用 sh:entailment,请参阅https://www.w3.org/TR/shacl/#shacl-rdfs

如果你事先知道子属性,你还可以使用替代路径并枚举 | 中的所有子属性。列表,请参阅https://www.w3.org/TR/shacl/#property-path-alternative