Consider the following instance of SomeClass
:
instances:some_thing1
a semapi:SomeClass ;
semapi:hasChainTo (
[ ... ] [ ... ] [ ... ]
) .
I need every instance (some_thing2
, some_thing3
, etc.) to have its hasChainTo
property point at the same list of blank nodes (as in there is only one copy of it). I need to maintain the list of blank nodes syntax because the chains get very deep and this syntax is very fluid for writing out each chain (for SomeClass2
, SomeClass3
, etc.).
If I simply make a base class and subClassOf from it, the hasChainTo
property inherits but not the object it's pointing to. This intuitively makes sense but I need the other behavior.
How can this be accomplished?
If you want to refer to the same thing from multiple nodes in the graph, you should give it a URI. It doesn't have to be a full
http:
URI - you could use a UUID:Don't confuse RDFS/OWL sub-classes with inheritance of state and behaviour in object-oriented languages. The class hierarchy in RDFS is for classifying nodes - i.e. assigning them to a class, where a class is some set of resources. There is no direct equivalent of the code-reuse you get from inheritance in languages like Java.
You're probably working in RDF(S), and not in OWL, but if you do have the ability to use OWL based tools, and for the sake of anyone who finds this question and can use OWL based tools, here's an OWL-based answer.
If you want every instance of a class (including instances of its subclasses) to have some property value in common, you can use an Individual Value Restriction. In the Manchester syntax, you can say that instances of
SomeClass
all have the valuesharedIndividual
for the properyhasValue
by the axiom:Then every instance of
SomeClass
has the typehasValue value sharedIndividual
, which means that the instance hassharedIndividual
as a value for thehasValue
property.Here's the N3 serialization of an ontology with a class
SomeClass
and two subclassesSomeSubClass
andAnotherSubClass
. Each of the three classes has a declared individual. The typehasValue value sharedIndividual
is a superclass ofSomeClass
.With this ontology loaded in Protégé and with Pellet attached for reasoning, asking which individuals have
sharedValue
as a value of thehasValue
property shows all the individuals.