In short. typeof assigns RDF types, while resource selects an identifiable nested resource for RDFa properties.
Definition: In RDFa,
typeofassigns one or more RDF types to a subject, whileresourcesupplies a resource that can identify the subject or the object of a relationship. In nested HTML, these attributes determine which entity receives the properties inside the element.
Key facts
- W3C defines
typeofas a whitespace-separated list of terms, CURIEs or absolute IRIs that indicate the RDF types associated with a subject in its RDFa Core specification. resourceexpresses the partner resource of a relationship that is not intended to be navigable, such as a clickable link, according to the same RDFa Core attribute definition.- The RDFa Primer describes
resourceas the exact URL to which the contained RDFa markup applies. - A nested
resourcevalue overrides the outer value for markup inside its containing element, as shown by the Primer's photo example.
How does typeof choose the typed subject?
typeof creates typing triples whose predicate is always rdf:type. The RDFa Core processing rules give about priority when it is present. If about is absent and an element only defines a possible subject with resource, that resource becomes the typed resource. If no identifier is supplied in this situation, the processor creates a blank node.
This example gives the nested country a URL and a type. The outer about identifies the person, while rel makes the nested element describe the relationship's object.
<div about="http://dbpedia.org/resource/Albert_Einstein">
<div rel="dbp:birthPlace"
resource="http://dbpedia.org/resource/German_Empire"
typeof="http://schema.org/Country">
</div>
</div>
The resulting type statement has the German Empire resource as its subject and http://schema.org/Country as its object.
What does resource change in nested markup?
The RDFa Primer uses resource to give each blog entry its own context on a page containing several entries. Relative and absolute URLs are both permitted. The value applies to the contained properties until a nested element supplies another resource.
<div resource="/alice/posts/trouble_with_bob">
<h2 property="title">The trouble with Bob</h2>
<div resource="http://example.com/bob/photos/sunset.jpg">
<span property="title">Beautiful Sunset</span>
<span property="creator">Bob</span>
</div>
</div>
Here, the inner title and creator describe the photo resource. The outer resource remains the context for properties outside the nested div.
What happens when an identifier is missing?
An element with typeof but without about or resource can create a fresh blank node. The RDFa Core processing section describes this form as shorthand for a resource attribute pointing to a newly created blank node. The Primer uses the pattern for a person whose name, email address and phone number are marked with property; those values are associated with the new node of type Person.
The distinction matters when checking extracted data. A URL-bearing resource gives the nested entity an identifier that other statements can use, whereas an isolated typeof describes an entity whose identifier is internal to the RDFa processor.
How can a page be checked?
Start at the outer element and record the current subject. RDFa Core says that parsing begins with the IRI of the document, or with a value supplied by a host-language mechanism such as an HTML base element. Then inspect each nested element for about, resource, rel, property and typeof. The combination determines whether the element changes the subject, creates a relationship object, or adds a type to the current resource.
Related terms
- RDFa
- Structured data
- How does the RDFa vocab attribute simplify Schema.org markup?
- How does RDFa prefix map short names to vocabulary URLs?
FAQ
Is typeof a property name?
No. typeof supplies RDF type information, and RDFa Core states that its predicate is always rdf:type. A property attribute expresses a relationship to a literal or resource.
Does resource always become the subject?
No. In a nested relationship such as rel plus resource, the resource is the relationship's object and typeof types that object. In an element used only to define a possible subject resource, it becomes the typed resource.
What is the difference between resource and about?
about directly establishes the subject context. resource can provide the partner resource of a relationship and can also supply the identifier for a typed nested entity when the element has no about.
Sources
- W3C, "RDFa 1.1 Primer - Third Edition", 17 March 2015
- W3C, "RDFa Core 1.1 - Third Edition", 17 March 2015
Check how a page reads to answer engines. Open the GEO score analyzer