sh:NodeShape & sh:targetClass

Bind a shape to a class.

0/3 done

Theory

A sh:NodeShape is a constraint document targeting a class:

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

:NinjaShape a sh:NodeShape ;
  sh:targetClass :Ninja ;
  sh:property [ sh:path foaf:name ; sh:minCount 1 ; sh:datatype xsd:string ] .

A validator reports any :Ninja instance missing a string foaf:name.

Validation, not entailment — the exact opposite of OWL. OWL/RDFS make your graph grow by adding inferred triples; SHACL leaves the graph alone and produces a report listing every node that violates a shape. Same data, two complementary questions: OWL asks what else is true?, SHACL asks is this data well-formed? Use OWL to enrich, SHACL to gatekeep.

Analogy

Think of a SHACL shape as a code review checklist for your graph: not how the data should look in detail, but what must be true for it to be considered well-formed.

And like a good code-review checklist, the value is in the rejection: shapes catch the malformed pull-request before it lands in main, so the rest of your pipeline can assume well-formed inputs.

Visualization

Shape targetClass :Master :teaches minCount 1 :teaches class :Ninja :Master rows validated against shape

A shape sits next to your data and asks: does every targetClass instance satisfy these constraints?

Read the diagram left-to-right: the dashed box on the left is the shape (the rules); the solid box on the right is the data (the :Master rows). The validator walks every targeted instance and emits a report — the data itself is never modified.

Reading in progress · 0 of 3 activities done