0

我正在寻找为我的本体中具有特定单位的某些属性制作一些 SHACL 形状。例子:

我的实例数据看起来像这样:

otlc:surgeprotector_1
  rdf:type otlc:Surgeprotector ;
  otlc:Nominal_voltage[
      rdf:type otlc:QuantityValue ;
      rdf:value "225"^^xsd:float ;
      otlc:hasUnit unit:KiloV ;
    ] ;
.

然后我有一些形状来验证这些数据:

otlc:Nominal_voltageShape
  rdf:type sh:PropertyShape ;
  sh:path otlc:Nominal_voltage ;
  sh:class otlc:QuantityValue ;
  **otlc:hasUnit unit:KiloV ;**
  sh:maxCount 1 ;
  sh:minCount 1 ;
.

otlc:SurgeprotectorShape
  rdf:type sh:NodeShape ;
  sh:property otlc:Nominal_voltageShape ;
  sh:targetClass otlc:Surgeprotector ;
.

我的问题:如何在我的本体中的每个属性的实例数据中为谓词“otlc:hasUnit”指定给定的单位?我想要的最终结果是为浪涌保护器设置一个节点形状,为属性“nominal_voltage”设置一个属性形状,以将nominal_voltage 的值限制为单位:KiloV。我希望有某种我没有听说过/意识到我可以在这里使用的 shacl 关键字来添加到我的 propertyshape 中(现在,我在 ** 中输入了我想象的 shacl 存在的内容)。(例如,sh:pattern 可用于使用正则表达式指定值,但我想指定我的值的一段元数据的值,如果这有意义的话......)

提前致谢!罗宾

4

1 回答 1

1

我相信您可以将突出显示的行替换为

sh:property [
    sh:path otlc:hasUnit ;
    sh:hasValue unit:KiloV ;
] ;

这意味着该属性形状必须适用于周围属性形状的所有值,即 otlc:Nominal_voltage 的所有值。

或者,您可以在更高一级的属性形状中使用路径表达式,例如

otlc:SurgeprotectorShape
    ...
    sh:property [
        sh:path ( otlc:Nominal_voltage otlc:hasUnit ) ;
        sh:hasValue unit:KiloV ;
    ] ;

请注意,sh:hasValue 也意味着 sh:minCount 1,即该值必须存在。您可能需要添加 sh:maxCount 1 作为额外保护。

于 2021-07-02T01:50:06.263 回答