例如在 Java 中,我可以通过将一个类声明为 final 来关闭它。但是,它仍将继承其超类:
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);}
}
但是在 SHACL 中这似乎不起作用:
@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
有没有办法在 SHACL 中使用带有继承的封闭形状?