Principle:AKSW RDFUnit SHACL Constraint Validation
| Knowledge Sources | |
|---|---|
| Domains | Semantic_Web, Data_Quality, domain:Validation |
| Last Updated | 2026-10-16 00:00 GMT |
Overview
A W3C-standardized framework for validating RDF data against shape constraints that specify structural and value requirements for nodes in a graph.
Description
SHACL (Shapes Constraint Language) is a W3C recommendation for describing and validating RDF data. A shape defines constraints on a focus node—typically targeting nodes of a certain RDF type or matching a selector. Constraints include cardinality (sh:minCount, sh:maxCount), datatype (sh:datatype), property paths (sh:path), logical combinators (sh:and, sh:or, sh:not, sh:xone), and SPARQL-based constraints (sh:sparql). RDFUnit implements the SHACL standard by converting shapes into executable test cases: each constraint on a shape becomes a test case that, when executed, produces a result indicating whether the focus node conforms or violates the constraint.
RDFUnit supports multiple SHACL execution levels: shaclLite (returns failing nodes only), shacl (extended results with all variable annotations), and integrates SHACL with its own pattern-based test generation for combined validation.
Usage
Use this principle when you have SHACL shapes (Turtle or RDF/XML) and need to validate RDF data against them. SHACL is preferred over ad-hoc SPARQL checks because shapes are declarative, reusable, and standardized. When OWL ontologies are also available, combine with Principle:AKSW_RDFUnit_Pattern_Based_Test_Generation for broader coverage.
Theoretical Basis
A SHACL shape graph contains node shapes and property shapes:
ex:PersonShape a sh:NodeShape ;
sh:targetClass ex:Person ;
sh:property [
sh:path ex:name ;
sh:minCount 1 ;
sh:datatype xsd:string ;
] .
RDFUnit converts each constraint into a SPARQL test query:
# Generated test: find Persons without a name
SELECT ?this WHERE {
?this a ex:Person .
FILTER NOT EXISTS { ?this ex:name ?name . }
}
Logical constraints (sh:and, sh:or, sh:xone, sh:not) are evaluated as groups: each sub-constraint produces results independently, and the group's result is determined by the logical operator.
Related Pages
Implemented By
- Implementation:AKSW_RDFUnit_ShaclTestGenerator_Generate
- Implementation:AKSW_RDFUnit_TestExecutor_Execute