RDF Schema - how to create instances?

╄→гoц情女王★ 提交于 2020-01-02 09:58:47

问题


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.


回答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.



来源:https://stackoverflow.com/questions/37311789/rdf-schema-how-to-create-instances

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!