Merge pull request #652 from strangepleasures/JENA-1797
JENA-1797: Shapes with class-based targets (sh:targetClass) are not applied to subclass instances
diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/validation/ValidationProc.java b/jena-shacl/src/main/java/org/apache/jena/shacl/validation/ValidationProc.java
index 12e1027..7c862fe 100644
--- a/jena-shacl/src/main/java/org/apache/jena/shacl/validation/ValidationProc.java
+++ b/jena-shacl/src/main/java/org/apache/jena/shacl/validation/ValidationProc.java
@@ -35,9 +35,7 @@
import org.apache.jena.shacl.parser.PropertyShape;
import org.apache.jena.shacl.parser.Shape;
import org.apache.jena.sparql.path.Path;
-import org.apache.jena.vocabulary.RDF;
-import static org.apache.jena.shacl.lib.G.hasType;
import static org.apache.jena.shacl.lib.G.isOfType;
public class ValidationProc {
@@ -273,16 +271,14 @@
Node targetObj = target.getObject();
switch(target.getTargetType()) {
case targetClass:
- return G.listPO(data, RDF.Nodes.type, targetObj);
+ case implicitClass:
+ return G.listAllNodesOfType(data, targetObj);
case targetNode:
return Collections.singletonList(targetObj);
case targetObjectsOf:
return G.setSP(data, null, targetObj);
case targetSubjectsOf:
return G.setPO(data, targetObj, null);
- case implicitClass:
- // Instances of the class and its subtypes.
- return G.listAllNodesOfType(data, targetObj);
default:
return Collections.emptyList();
}
@@ -298,15 +294,14 @@
Node targetObject = target.getObject();
switch (target.getTargetType()) {
case targetClass:
- return hasType(data, node, targetObject);
+ case implicitClass:
+ return isOfType(data, node, targetObject);
case targetNode:
return targetObject.equals(node);
case targetObjectsOf:
return data.contains(null, targetObject, node);
case targetSubjectsOf:
return data.contains(node, targetObject, null);
- case implicitClass:
- return isOfType(data, node, targetObject);
default:
return false;
}