For example in Java, I can close off a class by declaring it as final. It will still inherit from its superclass, however:
public abstract class Super {
final boolean test = true;
}
public final class Sub extends Super
{
public static void main(String[] args) {System.out.println(new Sub().test);}
}
However in SHACL this does not seem to work:
@prefix : <http://test.ex/>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix sh:<http://www.w3.org/ns/shacl#>.
:Super a owl:Class.
:Sub a owl:Class;
rdfs:subClassOf :Super.
:Sub1 a :Sub;
:exampleProperty :TestObject.
:SuperShape a sh:NodeShape;
sh:targetClass :Super;
sh:property [sh:path :exampleProperty].
:SubShape a sh:NodeShape;
sh:targetClass :Sub;
sh:ignoredProperties ( rdf:type );
sh:closed true.
pyshacl -s test.ttl test.ttl
Validation Report
Conforms: False
Results (1):
Constraint Violation in ClosedConstraintComponent (http://www.w3.org/ns/shacl#ClosedConstraintComponent):
Severity: sh:Violation
Source Shape: :SubShape
Focus Node: :Sub1
Value Node: :TestObject
Result Path: :exampleProperty
Message: Node :Sub1 is closed. It cannot have value: :TestObject
Is there any way to use closed shapes in SHACL with inheritance?