You've built an ontology. You've loaded data. But how do you know your data actually conforms to your model?
OWL can tell you what could be true. SHACL tells you what must be true.
SHACL (Shapes Constraint Language) is a W3C standard for validating RDF graphs against a set of conditions called shapes. Think of it as a schema validator for knowledge graphs — similar to JSON Schema for JSON or XSD for XML, but designed specifically for RDF data.
This is the most fundamental difference. Consider this Northwind example:
# OWL ontology says: Employee has a reportsTo property nwo:reportsTo a owl:ObjectProperty ; rdfs:domain nwo:Employee ; rdfs:range nwo:Employee . # Data: Alice is an Employee with no reportsTo value nwr:alice a nwo:Employee ; nwo:firstName "Alice" .
OWL says: This is perfectly fine. Alice probably reports to someone — we just don't know who yet. The absence of reportsTo is not an error; it's just incomplete information. This is the Open World Assumption.
reportsTo
SHACL says: If the shape requires reportsTo, then Alice is in violation. Missing data is a concrete problem that must be fixed. This is the Closed World Assumption.
SHACL organizes constraints into shapes — reusable constraint groups that target specific types of nodes.
A Node Shape targets all instances of a class and defines what properties they must/can have:
nws:EmployeeShape a sh:NodeShape ; sh:targetClass nwo:Employee ; sh:property [ sh:path nwo:firstName ; sh:datatype xsd:string ; sh:minCount 1 ; sh:maxCount 1 ; ] ; sh:property [ sh:path nwo:reportsTo ; sh:class nwo:Employee ; sh:maxCount 1 ; ] .
This shape says:
Employee
firstName
Each sh:property block is a Property Shape — it constrains a single property path:
sh:property
sh:property [ sh:path nwo:unitPrice ; # Which property sh:datatype xsd:decimal ; # Must be a decimal number sh:minCount 1 ; # Required (at least 1 value) sh:maxCount 1 ; # Single-valued (at most 1) sh:minExclusive 0 ; # Must be positive ] .
When SHACL validates data, it produces a Validation Report — an RDF graph describing what passed and what failed:
[] a sh:ValidationReport ; sh:conforms false ; sh:result [ a sh:ValidationResult ; sh:focusNode nwr:employee-1 ; sh:resultPath nwo:firstName ; sh:resultSeverity sh:Violation ; sh:resultMessage "Less than 1 values" ; sh:sourceConstraintComponent sh:MinCountConstraintComponent ; sh:sourceShape _:b1 ; ] .
This tells you:
nwr:employee-1
nwo:firstName
sh:Violation
sh:Warning
sh:Info
SHACL wins for RDF data because it speaks the same language as your data — triples, URIs, and graphs. The validation report is itself an RDF graph that you can query, store, and reason over.
In RDF Studio, SHACL serves three purposes:
The next articles in this guide walk through each of these capabilities with concrete Northwind examples.