首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SHACL联合形状

SHACL联合形状
EN

Stack Overflow用户
提问于 2020-11-17 07:49:35
回答 1查看 60关注 0票数 1

我为以下用例构建了一个SPARQL查询:如果IfcWallStandardCase有一个属性'FireRating',那么与之关联的门也应该有一个属性'FireRating‘。

数据图

代码语言:javascript
复制
@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查询

代码语言:javascript
复制
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.
   }}

我想为相同的SHACL形状添加框架。在SHACL高级特性中,最接近的选项是使用sh:union。下面是我的形状。

代码语言:javascript
复制
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]
        )
    ].

但是,它没有给出SPARQL查询所给出的结果。我哪里错了?任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2021-09-14 18:10:06

我不清楚你是否需要一个sh:规则。尝试以下操作:

代码语言:javascript
复制
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" ;
    ]
.

它可能不是一个完整的值,您可能希望使用sh:in来指定FireRating的值范围,但这样想可能是值得的,也许您可以调整以满足您的规范。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64867375

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档