1

関連するすべてのファイルの要旨がhttps://gist.github.com/James-Hudson3010/2588d9b17dd33e15922122b8b5cf1bd7にあります。

私が実行した場合:

$ pyshacl -a -f human employees.ttl

次の正しい検証レポートが表示されます...

Validation Report
Conforms: False
Results (3):
Constraint Violation in MaxInclusiveConstraintComponent (http://www.w3.org/ns/shacl#MaxInclusiveConstraintComponent):
    Severity: sh:Violation
    Source Shape: hr:jobGradeShape
    Focus Node: d:e4
    Value Node: Literal("8", datatype=xsd:integer)
    Result Path: hr:jobGrade
Constraint Violation in DatatypeConstraintComponent (http://www.w3.org/ns/shacl#DatatypeConstraintComponent):
    Severity: sh:Violation
    Source Shape: hr:jobGradeShape
    Focus Node: d:e3
    Value Node: Literal("3.14", datatype=xsd:decimal)
    Result Path: hr:jobGrade
Constraint Violation in MinCountConstraintComponent (http://www.w3.org/ns/shacl#MinCountConstraintComponent):
    Severity: sh:Violation
    Source Shape: hr:jobGradeShape
    Focus Node: d:e2
    Result Path: hr:jobGrade

ただし、employees.ttl をスキーマ、形状、およびインスタンス データを含む 3 つのファイルに分割して実行すると、次のようになります。

pyshacl -s shape.ttl -e schema.ttl -a -f human instance.ttl

結果は次のとおりです。

Validation Report
Conforms: True

pyshacl を正しく呼び出していると思います。

4

1 に答える 1

2

個々のファイルを使用する場合、pySHACL は Shape ファイルの NodeShape を何に関連付けるかを知る方法がありませんhr:Employee。その単一のファイルにあるときを知っているようです(おそらく、ファイル内のすべてのクラスに対して実行されますか??)。

そう:

  1. hr:Employeeクラス名をオーバーロードしないように、Employee シェイプの名前を変更します。hr:EmployeeShape
  2. sh:targetClassディレクティブに追加します。
hr:EmployeeShape
   a sh:NodeShape ;
   sh:targetClass hr:Employee ;
   sh:property hr:nameShape ;
   sh:property hr:jobGradeShape .

次に、複数ファイルの呼び出しは、単一ファイルの呼び出しと同じ結果をもたらします。

pySHACL への呼び出しは正しいです!

于 2020-04-01T12:59:04.127 に答える