2

If I have a class, for example "Animal", then I can use SHACL to validate its instances:

:Elefant a :Animal;
 :family    :Elephantidae;
 :order     :Proboscidea.
:AnimalShape a sh:NodeShape;
 sh:targetClass :Animal;
 sh:property [sh:Path :family], [sh:Path :order].

This works on DBpedia, where animals are modeled as instances, for example https://dbpedia.org/page/Elephant has rdf:type dbo:Mammal, which is an rdfs:subClass of dbo:Animal.

However assume I want to model animals as classes, because an elefant is just a set of actual elefant individuals:

:Elefant rdf:type owl:Class;
 rdfs:subClassOf :Animal;
 :family    :Elephantidae;
 :order     :Proboscidea.

This will not be validated using the before mentioned SHACL shape. How would do I need to adapt that shape to validate this?

Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118
  • 1
    Can you simply use metaclasses and attach the shape to the metaclass? Your lower example lacks the rdf:type triple for :Elefant, but that could be :AnimalClass rdfs:subClassOf rdfs:Class? – Holger Knublauch Jan 18 '22 at 22:59
  • @HolgerKnublauch: Added `rdf:type owl:Class` to :Elefant in the lower example. I did not know the term metaclass and will look it up, thanks! – Konrad Höffner Jan 19 '22 at 13:09
  • 1
    @HolgerKnublauch: With this approach I would need to attach `:MyAnimalSubClass rdf:type :AnimalClass.` to a large number of animals. Also I may not be able to modify the ontology under validation. Is there a simpler way that does not require adding a large amount of triples to the ontology? – Konrad Höffner Apr 17 '23 at 11:55
  • 1
    Unless you really plan to create instances, e.g. store individual Elephants, you may want to reconsider using classes in the first place. There is no free lunch here. If you really still want owl:Classes and no other metaclass, you can define a node shape that has sh:targetClass owl:Class. – Holger Knublauch Apr 18 '23 at 12:37
  • 1
    This really is an unfortunate limitation of SHACL that I was not aware of. There is ample use cases where one wants to annotate data with a **class** that is a **subClassOf** of some higher-level class. In these ontologies classes cannot be changed to be individuals since the classification of the concepts often depends on OWL class constructors. – Henriette Harmse Apr 20 '23 at 12:25

0 Answers0