I'm using the Apacha Java Jena engine.
I want to derive a ex:hasFather relationship by going through all instances of <Man> and then seeing if they are the subject of a ex:hasChild relationship. This would be my NodeShape to derive it. I know that I could target <Man> in the first place, but let's say it want to to it this way. Using the Jena engine the condition doesn't seem to take effect, it still targets <Woman> aswell, leading to wrong ex:hasFather triples. According to documentation the condition should be executed before the rule itself gets executed.
<ParentsShape> a sh:NodeShape ;
sh:targetClass <Person> ;
sh:rule [
a sh:TripleRule ;
sh:subject [ sh:path :hasChild ] ;
sh:predicate :hasFather ;
sh:object sh:this ;
sh:condition [
sh:targetClass <Man> ;
]
] .
How would I have to rewrite my sh:condition in order for it to work?
The problem was that sh:targetClass
is only used for selecting focus nodes, not for checking that a node is of a certain class. For that sh:class
needs to be used. Replacing that part, I was able to derive the relationship.