SHACL validation reports

From BITPlan cr Wiki
Revision as of 17:21, 10 July 2024 by Wf (talk | contribs) (Created page with "== SHACL Validation Reports == SHACL (Shapes Constraint Language) validation reports are structured documents that provide detailed information about the results of validatin...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

SHACL Validation Reports

SHACL (Shapes Constraint Language) validation reports are structured documents that provide detailed information about the results of validating RDF data against SHACL shapes. These reports are crucial for understanding the conformance of data to predefined constraints and for identifying and addressing data quality issues.

Structure of a SHACL Validation Report

A SHACL validation report is itself an RDF graph, typically serialized in Turtle or JSON-LD format. The report contains the following key components:

Conforms Property

The sh:conforms property indicates whether the validated data graph conforms to all shapes. It has a boolean value:

  • true: The data graph conforms to all shapes
  • false: At least one shape was violated

Result Nodes

For each constraint violation, the report includes a result node with the following properties:

  • sh:resultSeverity: Indicates the severity of the violation (sh:Violation, sh:Warning, or sh:Info)
  • sh:focusNode: The RDF node that was validated against the shape
  • sh:resultPath: The property path related to the constraint violation (if applicable)
  • sh:value: The RDF node value that caused the violation (if applicable)
  • sh:sourceShape: The specific shape that was violated
  • sh:sourceConstraintComponent: The constraint component that was violated
  • sh:message: A human-readable message describing the violation

Example SHACL Validation Report

Here's a simple example of a SHACL validation report in Turtle format:

@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix ex: <http://example.com/> .

[] a sh:ValidationReport ;
   sh:conforms false ;
   sh:result [
     a sh:ValidationResult ;
     sh:resultSeverity sh:Violation ;
     sh:focusNode ex:John ;
     sh:resultPath ex:age ;
     sh:value "twenty" ;
     sh:sourceShape ex:PersonShape ;
     sh:sourceConstraintComponent sh:DatatypeConstraintComponent ;
     sh:message "Value is not a valid integer" ;
   ] .

Using SHACL Validation Reports

SHACL validation reports can be used for various purposes:

  1. Data Quality Assurance: Identify and correct data that doesn't conform to the expected structure or constraints.
  2. Application Development: Ensure that data meets the requirements of applications before processing.
  3. Data Integration: Validate data from external sources before integrating it into a system.
  4. Compliance Checking: Verify that data adheres to specific standards or regulations.

Tools for Working with SHACL Validation Reports

Several tools can generate and process SHACL validation reports:

  • TopBraid Composer: A commercial tool for creating and running SHACL validations
  • Apache Jena: An open-source Java framework that includes SHACL validation capabilities
  • RDF4J: Another open-source framework with SHACL support
  • pyshacl: A Python library for SHACL validation


External Links