[英]Does SHACL provide the capability to define “target shapes”?
我认为答案可能是否定的,但 SHACL 中是否存在定义“目标形状”作为 targetClass、targetNode、targetObjectsOf、targetSubjectsOf 的替代方案的能力?
能够创建目标选择器似乎可以简化 SHACL 规则。
我发现自己必须使用 Boolean 逻辑来完成相同的事情,这需要相同的检查出现在需要这种类型过滤的所有形状中。
例如:
如果可能的话,创建我想成为验证的选择器/过滤器:
# human made objects that are the object of an equivalent statement - these external references could be in the graph along with our data
# but the crm:E22_Human-Made_Object class is still the same
la:isSparseObject
a sh:PropertyShape;
sh:path [ sh:inversePath la:equivalent ];
sh:class crm:E22_Human-Made_Object ; # the value node must be a HumanMadeObject
sh:minCount 1;
.
但是由于我还没有找到“选择器”功能,所以我使用 sh:or 来忽略某些人。
la:hasAtLeastOnePrimaryName
a sh:PropertyShape;
sh:or (
la:isSparseObject
[
sh:property [
sh:path crm:P1_is_identified_by;
sh:qualifiedValueShape [
…
la:object
a sh:NodeShape;
sh:targetsClass crm:E22_Human-Made_Object; #
la:hasAtLeastOnePrimaryName;
.
我更喜欢使用假设的 sh:targetsShape 和 sh:targetsSeverity 属性,如下所示:
la:sparseObject
a sh:NodeShape;
sh:targetsClass crm:E22_Human-Made_Object; #
sh:targetsShape la:isSparseObject;
sh:targetsSeverity sh:Warning;
# the focusnodes for this shape include all E22_Human-Made_Objects that la:isSparseObject validates with sh:Warning level and below
# so I can accumulate all sparseObject properties here
# this approach allows me to easily segment my instances into data shape based groupings
…
所以,问题是:这可能吗? 不是,有没有比我找到的解决方案更好的方法来解决这个问题?
谢谢!
啊,看起来 SPARQLTarget 就是这样做的!
https://w3c.github.io/shacl/shacl-af/#SPARQLTarget
ex:PeopleBornInCountryTarget
a sh:SPARQLTargetType ;
rdfs:subClassOf sh:Target ;
sh:labelTemplate "All persons born in {$country}" ;
sh:parameter [
sh:path ex:country ;
sh:description "The country that the focus nodes are 'born' in." ;
sh:class ex:Country ;
sh:nodeKind sh:IRI ;
] ;
sh:select """
PREFIX ex: <http://example.com/ns#>
SELECT ?this
WHERE {
?this a ex:Person .
?this ex:bornIn $country .
}
""" .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.