问题描述
我想在RDFS文件中有类的实例,但是我不知道该怎么做.
I want to have instances of classes in my RDFS file, but I don't know how to do it.
我的课:
<rdfs:Class rdf:ID="Turns">
<rdfs:range rdf:resource="Literal"/>
</rdfs:Class>
我的财产:
<rdf:Property rdf:ID="has_Turns">
<rdfs:domain rdf:resource="#Device"/>
<rdfs:range rdf:resource="#Turns_Frequency"/>
</rdf:Property>
我想获得带有"has_Turns"属性的"Turns"类的实例.我尝试过这样的事情:
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>
…但是主类是"Turns_Instance",反之则不起作用.更何况我不知道将财产放在何处.所有实例都应位于RDFS文件中.
… 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.
推荐答案
实例可以在类定义中定义为:
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>
还请注意,范围定义属于属性定义,而不是类定义.因此,真正的错误可能是使用RDF/XML文本序列化.任何RDF编辑器都应该能够使用和生成Turtle,这是人类可读的.在这种情况下,类和实例的定义如下所示:
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 .
除了能够轻松地看到"三元组之外,RDF作为对象表示形式也变得更加清晰,这对于理解RDF的工作原理是一个巨大的优势.
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.
这篇关于RDF架构-如何创建实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!