https://github.com/Sveino/Inst4CIM-KG/tree/develop/shacl-improved#use-shmaxlength-instead-of-sparql:
Consider this overcomplicated shape in CGMES-NC/r2.3/ap-con/ttl/NC-AP-Con-Complex-IdentifiedObjecStringLength-SHACL.ttl:
io:IdentifiedObjectStringLength a sh:NodeShape ;
sh:property io:IdentifiedObject.name-stringLength;
sh:targetNode cim:IdentifiedObjectStringLength .
io:IdentifiedObject.name-stringLength
a sh:PropertyShape ;
sh:description "The string IdentifiedObject.name has a maximum of 128 characters." ;
sh:sparql io:IdentifiedObject.name-stringLengthSparql ;
sh:path rdf:type ;
sh:group io:IOstringLength ;
sh:name "C:452:ALL:IdentifiedObject.name:stringLength" ;
sh:order 1 ;
sh:severity sh:Violation .
io:IdentifiedObject.name-stringLengthSparql
a sh:SPARQLConstraint ;
sh:message "String length is greater than 128 characters." ;
sh:prefixes cim: ;
sh:select """
SELECT $this ?value
WHERE {
?s cim:IdentifiedObject.name ?value
FILTER (STRLEN(?value)>128) .
}""" .
We don't need the fake node, the misleading sh:path rdf:type, or in fact any SPARQL. We can target by class or property and simplify it to:
io:IdentifiedObjectStringLength a sh:NodeShape ;
sh:property io:IdentifiedObject.name-stringLength;
sh:targetSubjectsOf cim:IdentifiedObject.name .
io:IdentifiedObject.name-stringLength
a sh:PropertyShape ;
sh:description "The string IdentifiedObject.name has a maximum of 128 characters." ;
sh:path cim:IdentifiedObject.name ;
sh:maxLength 128;
sh:group io:IOstringLength ;
sh:name "C:452:ALL:IdentifiedObject.name:stringLength" ;
sh:order 1 ;
sh:severity sh:Violation .
@HarisVranaj can you add @nataschake to this repo? She's made a fix and I want to assign to her.
https://github.com/Sveino/Inst4CIM-KG/tree/develop/shacl-improved#use-shmaxlength-instead-of-sparql:
Consider this overcomplicated shape in CGMES-NC/r2.3/ap-con/ttl/NC-AP-Con-Complex-IdentifiedObjecStringLength-SHACL.ttl:
We don't need the fake node, the misleading sh:path rdf:type, or in fact any SPARQL. We can target by class or property and simplify it to:
Alternative or Disjunction Instead of SPARQL
Use sh:maxCount Instead of SPARQL
Use sh:maxLength Instead of SPARQL
Use sh:equals Instead of SPARQL
Generalize Shapes
Use targetObjectsOf Instead of SPARQL Subquery
@HarisVranaj can you add @nataschake to this repo? She's made a fix and I want to assign to her.