I am attempting to insert a triple when a particular SHACL violation occurs. It seems as if I would use the sh:update, but I can't seem to get it right.
I have a Person class that has a property Comment. I can easily update the Person by
ex:Person
rdf:type rdfs:Class ;
rdf:type sh:Shape ;
rdfs:label "Person" ;
rdfs:subClassOf rdfs:Resource ;
sh:property [
sh:predicate ex:Comment ;
sh:datatype xsd:string ;
sh:minCount 1 ;
INSERT {
?s ex:Comment \"inserted Comments\" .
}
WHERE {
?s rdf:type ex:Person . }""" ;
] ;
sh:property [
sh:predicate ex:firstName ;
sh:datatype xsd:string ;
sh:minCount 1 ;
sh:name "first name" ;
] ;
sh:property [
sh:predicate ex:gender ;
sh:class ex:Gender ;
sh:description "A Person's gender" ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:name "gender" ;
] ;
sh:property [
sh:predicate ex:lastName ;
sh:datatype xsd:string ;
sh:description "last name " ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:name "last name" ;
] ;
sh:property [
sh:predicate ex:mother ;
sh:class ex:Person ;
sh:description "A Person's mother";
sh:maxCount 1 ;
sh:name "mother" ;
sh:nodeKind sh:IRI ;
sh:shape ex:FemaleShape ;
] ;
sh:update """INSERT {
?s ex:Comment \"inserted Comments\" .
}
WHERE {
?s rdf:type ex:Person . }""" ;
.
ex:Person
rdf:type rdfs:Class ;
rdf:type sh:Shape ;
rdfs:label "Person" ;
rdfs:subClassOf rdfs:Resource ;
sh:property [
sh:predicate ex:Comment ;
sh:datatype xsd:string ;
sh:minCount 1 ;
sh:update """INSERT {
?s ex:Comment \"inserted Comments\" .
}
WHERE {
?s rdf:type ex:Person . }""" ;
] ;
sh:property [
sh:predicate ex:firstName ;
sh:datatype xsd:string ;
sh:minCount 1 ;
sh:name "first name" ;
] ;
sh:property [
sh:predicate ex:gender ;
sh:class ex:Gender ;
sh:description "A Person's gender" ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:name "gender" ;
] ;
sh:property [
sh:predicate ex:lastName ;
sh:datatype xsd:string ;
sh:description "last name " ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:name "last name" ;
] ;
sh:property [
sh:predicate ex:mother ;
sh:class ex:Person ;
sh:description "A Person's mother " ;
sh:maxCount 1 ;
sh:name "mother" ;
sh:nodeKind sh:IRI ;
sh:shape ex:FemaleShape ;
] ;
.