3

I want to have instances of classes in my RDFS file, but I don't know how to do it.

My class:

<rdfs:Class rdf:ID="Turns">
   <rdfs:range rdf:resource="Literal"/>
</rdfs:Class>

My property:

<rdf:Property rdf:ID="has_Turns">
   <rdfs:domain rdf:resource="#Device"/>
   <rdfs:range rdf:resource="#Turns_Frequency"/>
</rdf:Property>

I want to get an instance of class "Turns" with a "has_Turns" property. I tried something like this:

<Turns_Instance rdf:ID="Turns">…</Turns_Instance>

… but it takes that the main class is "Turns_Instance", the other way round it doesn't work. What's more I don't know where to put the property. All instances should be in RDFS file.

unor
  • 92,415
  • 26
  • 211
  • 360
mystery-user
  • 105
  • 1
  • 2
  • 11

1 Answers1

1

The instance can be defined within the class definition as:

<ex:Turns rdf:about="http://example.org/ex1#Turns_Instance">
   <ex:hasTurns>
      <ex:Turns_Frequency rdf:about="http://example.org/ex1#Turns_Frequency_Instance"/>
   </ex:hasTurns>
</ex:Turns>

Note also that range definitions belong on property definitions, not class definitions. So the the real bug may be using the RDF/XML text serialization. Any RDF editor should be able to consume and generate Turtle, which is human readable. In that case the class and instance definition look like the following:

@prefix ex: <http://example.org/ex1#> .

ex:Turns
  rdf:type owl:Class .
ex:Turns_Instance
  rdf:type ex:Turns ;
  ex:hasTurns ex:Turns_Frequency_instance .
ex:Device
  rdf:type owl:Class .
ex:Turns_Frequency
  rdf:type owl:Class .
ex:hasTurns
  rdf:type owl:ObjectProperty ;
  rdfs:domain ex:Turns ;
  rdfs:range ex:Turns_Frequency .

In addition to being able to easily "see" the triples, RDF as an object representation become much clearer, which is a huge advantage for understanding how RDF works.

scotthenninger
  • 3,921
  • 1
  • 15
  • 24