简体   繁体   English

SHACL联合形状

[英]SHACL union shapes

I have framed a SPARQL query for the following use-case: If IfcWallStandardCase have a property 'FireRating', then the doors associated with it should have a property 'FireRating' as well.我为以下用例构建了一个 SPARQL 查询:如果 IfcWallStandardCase 有一个属性“FireRating”,那么与之关联的门也应该有一个属性“FireRating”。

The Data Graph数据图

@prefix inst1: <https://someHost.com/PROJ1001#> .
@prefix :      <http://test.com/#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ifcowl: <https://www.buildingsmart-tech.org/ifcOWL/IFC4_ADD1#> .
@prefix s4bldg: <https://saref.etsi.org/saref4bldg/> .
@prefix bot:   <https://w3id.org/bot#> .

inst1:Wall1  a  ifcowl:IfcWallStandardCase ;
    s4bldg:FireRating "2" ;
    bot:containsSubElement  inst1:Door1, inst1:Door2.
inst1:Door1 a ifcowl:IfcDoor ;
    s4bldg:FireRating  "2" .
inst1:Door2 a ifcowl:IfcDoor .

SPARQL Query SPARQL 查询

SELECT ?door
WHERE {{
   ?wall rdf:type ifcowl:IfcWallStandardCase.
   ?wall bot:containsElement ?val.
   ?wall s4bldg:FireRating ?val.
   }UNION{
   ?door rdf:type ifcowl:IfcDoor.
   ?door s4bldg:FireRating ?val.
   }}

I want to frame a SHACL shape for the same.我想为相同的形状构建一个 SHACL 形状。 From the SHACL advanced features, the closest option is to use the sh:union.从 SHACL 高级功能中,最接近的选项是使用 sh:union。 Below, is my shape.下面,是我的形状。

bot:BuildingShape
    a sh:NodeShape ;
    sh:targetClass ifcowl:IfcWallStandardCase;
    sh:rule [
        sh:subject sh:this;
        sh:predicate s4bldg:FireRating;
        sh:object ifcowl:IfcWallStandardCase;
        sh:union(
            [sh:path ifcowl:IfcDoor]
            [sh:path s4bldg:FireRating]
        )
    ].

But, it does not give me the result given by the SPARQL query.但是,它没有给我 SPARQL 查询给出的结果。 Where am I going wrong?我哪里错了? Any help would be appreciated.任何帮助,将不胜感激。

It's not clear to me that you need a sh:rule for this.我不清楚您是否需要 sh:rule 为此。 Try the following:请尝试以下操作:

bot:BuildingShape
    a sh:NodeShape ;
    sh:targetClass ifcowl:IfcWallStandardCase;
    sh:property [
       sh:path bot:containsSubElement;
       sh:class ifcowl:IfcDoor ;
    ] ;
    sh:property [
        sh:path s4bldg:FireRating;
        sh:hasValue "2" ;
    ]
.

It may not be a full value, and you may want to use sh:in to specify the range of values for FireRating, but it may be worth thinking of it this way and maybe you can tweak to meet your specification.它可能不是一个完整的值,您可能想使用 sh:in 来指定 FireRating 的值范围,但可能值得以这种方式考虑它,也许您可​​以进行调整以满足您的规范。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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