5

In RDF 1.1 XML Syntax documentation rdf:resource is used as a shortened form when defining Empty Property Elements:

When a predicate arc in an RDF graph points to an object node which has no further predicate arcs, which appears in RDF/XML as an empty node element (or ) this form can be shortened. This is done by using the IRI of the object node as the value of an XML attribute rdf:resource on the containing property element and making the property element empty.

In RDF Schema 1.1 rdfs:Resource is defined as a class:

All things described by RDF are called resources, and are instances of the class rdfs:Resource. This is the class of everything. All other classes are subclasses of this class. rdfs:Resource is an instance of rdfs:Class.

How are the two related? Does an rdf:resource value always belong to rdfs:Resource class and the other way around?

4

1 回答 1

8

它们根本没有关系。他们只是碰巧共享一个名字,因为他们都资源有关。

术语“资源”是 RDF 数据模型的核心(毕竟它是资源描述框架)。一般而言,RDF 中的资源是可以通过 URI 标识的任何东西(关于空白节点和文字等事物如何落入此定义的技术细节很多,但为简单起见,我们将在这里忽略它)。

rdf:resource只是RDF/XML语法中的一个语法元素,即标识资源的属性,即属性值。例如,这是一个简单的 RDF 模型(1 个三元组),采用 RDF/XML:

<rdf:Description rdf:about="http://example.org/Bob">
    <foaf:address rdf:resource="http://example.org/address1"/>
</rdf:Description>

这里,http://example.org/Bob是主题资源,并且foaf:address是该主题的一个属性(用于将主题资源链接到一个值)。在这种情况下,属性值也是一个资源 ( http://example.org/address1),因此在 RDF/XML 语法中,我们使用rdf:resource属性来链接它。但是,如果您要以不同的语法(例如 Turtle)编写相同的 RDF 模型,您根本不会看到rdf:resource出现:

<http://example.org/Bob> foaf:address <http://example.org/address1> .

在 RDF Schema 中,类rdfs:Resource是所有资源的类。它是一个概念,而不是特定于语法的机制。由于 RDF 中的几乎所有东西都是资源,因此它是“顶级”类的东西。所有东西都是资源,所以如果你引入一个新类,例如“Person”,它将(自动)成为rdfs:Resource.

<http://example.org/Bob> rdf:type <http://example.org/Person> . 
<http://example.org/Bob> rdf:type rdfs:Resource . 

请注意,第二个三元组是第一个三元组的逻辑结果。因此,在实践中,几乎从未在 RDF 模型中明确写下 bob 是资源这一事实——如果需要,可以推断出来。

于 2019-07-07T23:19:41.177 回答