简体   繁体   English

SHACL 是否提供定义“目标形状”的能力?

[英]Does SHACL provide the capability to define “target shapes”?

I think the answer is probably no, but does there exist in SHACL the capability to define “target shapes” as an alternative to targetClass, targetNode, targetObjectsOf, targetSubjectsOf?我认为答案可能是否定的,但 SHACL 中是否存在定义“目标形状”作为 targetClass、targetNode、targetObjectsOf、targetSubjectsOf 的替代方案的能力?

Being able to create target selectors seems like something that would simplify SHACL rules in general.能够创建目标选择器似乎可以简化 SHACL 规则。

I'm finding myself having to use Boolean logic to accomplish the same thing which requires those same checks to appear in all shapes requiring that type of filtering.我发现自己必须使用 Boolean 逻辑来完成相同的事情,这需要相同的检查出现在需要这种类型过滤的所有形状中。

For example:例如:

Creating what I'd like to be a selector / filter for validations if that's possible:如果可能的话,创建我想成为验证的选择器/过滤器:

# 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;
.

But since I haven't found a “selector” feature, I'm using sh:or to ignore certain individuals.但是由于我还没有找到“选择器”功能,所以我使用 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;
.

What I'd prefer to do is use hypothetical sh:targetsShape and sh:targetsSeverity properties like this:我更喜欢使用假设的 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
…

So, the questions are: is this possible?所以,问题是:这可能吗? Is not, is there a better way of approaching the problem than the solution I've arrived at?不是,有没有比我找到的解决方案更好的方法来解决这个问题?

Thanks!谢谢!

Ah, it looks like SPARQLTarget does that!啊,看起来 SPARQLTarget 就是这样做的!

https://w3c.github.io/shacl/shacl-af/#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.

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