rdf - SHACL 联合形状
问题描述
我为以下用例构建了一个 SPARQL 查询:如果 IfcWallStandardCase 有一个属性“FireRating”,那么与之关联的门也应该有一个属性“FireRating”。
数据图
@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 查询
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。下面,是我的形状。
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 查询给出的结果。我哪里错了?任何帮助,将不胜感激。
解决方案
我不清楚你需要一个 sh:rule 为此。尝试以下操作:
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 的值范围,但这样考虑可能值得,也许您可以调整以满足您的规范。
推荐阅读
- arrays - Swift:CustomStringConvertible 数组数组,还有其他方法吗?
- c# - 正确的正则表达式将值放入 URL
- html - 对象 youtube 嵌入在 Firefox 中不起作用
- python - 当在循环中进行预测时,模型给出不同的分数 VS 当从模型列表中进行预测时
- java - 如何在关系的多方面使用复合主键在关系的多方面持久化数据
- python - python导入的变量没有在其他文件中更新
- python - 将 int 转换为具有可变字节长度的字节
- python - Celery:如何批量生产任务?
- reactjs - Chrome 扩展 UI 页面和内容脚本之间的通信问题
- scala - 为什么 Scala 中的 `def aPlusOne = a + 1` 和 `val aPlusOne = () => a + 1` 不同?