0

I'm trying to access to the property inherited of a parent class in RDF. I define an instance of my child class using the rdfs property subClassOf.

With a turtle syntax :

ex:myClass1 a owl:class;
           rdfs:range xsd:integer.

ex:myClass2 rdfs:subClassOf ex:myClass1.

# defining instance of my class

ex:instance1 ex:myClass1 1 .

ex:instance2 ex:myClass2 2 .

If I want to access to the property ex:property of all ex:myClass1 and his child. Can I admit that ex:myClass2 is a ex:myClass1 and write this SPARQL query

SELECT ?instance ?value WHERE{
    ?instance ex:myClass1 ?value .
}

to obtain the two values I've defined? Or rdfs:subClassOf doesn't define a child class as a more specificaly version of the parent class?

Thibaut Guirimand
  • 851
  • 10
  • 33
  • When you write `?instance ex:MyClass1 ?value`, you're using `ex:myClass1` as a property. Isn't it supposed to be a class? RDF properties and classes aren't like (some kinds of) object oriented programming; properties don't *belong* to classes, and they're not *inherited* among them. I'm not sure what you mean by `ex:instance1 ex:myClass1 1`. If you want ex:instance1 to be an instance of ex:myClass1, you'd say `ex:instance1 rdf:type ex:myClass1`. – Joshua Taylor Feb 12 '15 at 16:41
  • @JoshuaTaylor So if I really understand, I sould have written `ex:instance1 a ex:myClass1; rdfs:range 1.` instead of `ex:instance1 ex:myClass1 1 .`? And I can't declare `ex:instance2 a ex:myClass2; rdfs:range 2.` because the property using _rdfs:range_ don't belong to _ex:myClass2_? – Thibaut Guirimand Feb 12 '15 at 17:11
  • `rdfs:range` is used to declare the *range* of a property. E.g., you might have: `ex:Person a owl:Class . ex:hasMother a owl:ObjectProperty . ex:hasMother rdfs:range ex:Person`. Person is a class. hasMother is a property, and the range of hasMother is Person; i.e., the values of the hasMother property should be instances of Person. – Joshua Taylor Feb 12 '15 at 17:35

1 Answers1

0

To complement what Joshua tried to explain you are mixing the schema and data concepts.

I think what you should define is (in simplified RDFS syntax):

ex:property rdfs:domain ex:myClass1 .
ex:property rdfs:range xsd:integer .

ex:myClass2 rdfs:subClassOf ex:myClass1.

#this may be optional depending on the entailment regime your SPARQL enpoint uses    
ex:myClass1 a owl:class .

# defining instance of my class

ex:instance1 ex:property 1 .
ex:instance2 ex:property 2 .

then you can query

SELECT ?instance ?value WHERE{
    ?instance ex:property ?value .
}

depending on the entailment regime of your SPARQL endpoint, it is inferred through the ex:property that ex:instance1 and ex:instance23 are at least instances of ex:Class1 (if you want to make one of those a ex:Class2 you will have to add the triple ex:instance a ex:Class2 to your store)

Max
  • 685
  • 4
  • 14
  • rdfs:range is a "meta" -property for rdfs:Property class instances (and its subclasses) . Under normal use this is should not be a property of ex:Class1 otherwise you infer that ex:Class1 is a property (under suitable entailment regime that is) – Max Feb 12 '15 at 17:35