Search code examples
rdfsemantic-webrdfsrdf-xml

What is the difference between rdf:resource and rdfs:Resource?


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?


Solution

  • They are not related, at all. They just happen to share a name because they both have something to do with resources.

    The term "resource" is central to the RDF data model (it's Resource Description Framework, after all). A resource in RDF is, very generally speaking, anything that can be identified by a URI (there's heaps of technical details regarding how things like blank nodes and literals fall under this definition, but for simplicity's sake we'll ignore that here).

    rdf:resource is just a syntax element in the RDF/XML syntax, namely an attribute to identify the resource that is the property value. For example, here's a simple RDF model (1 triple), in RDF/XML:

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

    Here, http://example.org/Bob is the subject resource, and foaf:address is a property of that subject (used to link the subject resource to a value). The property value in this case is also a resource (http://example.org/address1), so in the RDF/XML syntax we use rdf:resource attribute to link it. If you were to write the same RDF model in a different syntax though (for example, Turtle), you wouldn't see rdf:resource appear at all:

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

    In RDF Schema, the class rdfs:Resource is the class of all resources. It is a concept, not a syntax-specific mechanism. Since pretty much anything in RDF is a resource, it is the 'top-level' class of things. All things are resources, so if you introduce a new class, for example "Person", it will (automatically) be a subclass of rdfs:Resource.

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

    Note that the second triple is a logical consequence of the first triple. Therefore, in practice, the fact that bob is a Resource is almost never explicitly written down in RDF models - if needed, it can be inferred.