SHACL validation reports
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 shapesh: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 violatedsh:sourceConstraintComponent
: The constraint component that was violatedsh: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:
- Data Quality Assurance: Identify and correct data that doesn't conform to the expected structure or constraints.
- Application Development: Ensure that data meets the requirements of applications before processing.
- Data Integration: Validate data from external sources before integrating it into a system.
- 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