In short. RDFa maps prefixes to IRI bases and expands CURIEs by joining each prefix with its reference.
Definition: An RDFa prefix declaration maps a short prefix to an IRI base. A compact URI expression, or CURIE, joins that prefix to a reference, so
dc:titlecan expand tohttp://purl.org/dc/terms/titlewhen the mapping is in scope.
Key facts
- The W3C RDFa 1.1 Primer describes
prefix:referenceas a syntax in which the URL associated with a prefix is concatenated with the reference. - RDFa Core defines
prefixas a whitespace-separated list of prefix-name and IRI pairs. - A CURIE has a prefix and a reference separated by a colon. Its value space is a set of IRIs.
- A prefix mapping applies to the element that declares it and its descendants. The innermost mapping for a prefix takes precedence.
How does a prefix declaration work?
The prefix attribute assigns a short name to a leading segment of an IRI. The RDFa Primer uses dc for the Dublin Core terms IRI and schema for the Schema.org IRI:
<body prefix="dc: http://purl.org/dc/terms/ schema: http://schema.org/">
<h2 property="dc:title">The trouble with Bob</h2>
<div property="schema:articleBody">...</div>
</body>
In this example, dc:title combines the dc mapping with title, while schema:articleBody combines the schema mapping with articleBody. The Primer says that the URL associated with the prefix is concatenated with the reference to create a full URL. RDFa Core gives the declaration shape as a whitespace-separated list of a prefix name, a colon, one or more spaces, and an IRI.
Where does the mapping apply?
The declaration applies to its current element and descendants. A declaration on body therefore covers the RDFa attributes below that element. The Primer also states that prefix can appear anywhere in the HTML file and affects the elements below it. A declaration on an inner element can replace an outer declaration for the same prefix, because RDFa Core gives the innermost mapping precedence.
For that reason, the same short name can expand to different IRIs in different parts of a document:
<div prefix="dbr: http://dbpedia.org/resource/">
<div about="dbr:Albert_Einstein">...</div>
</div>
<div prefix="dbr: http://someotherdb.org/resource/">
<div about="dbr:Albert_Einstein">...</div>
</div>
RDFa Core describes redefining prefixes within one document as a bad practice and recommends using the same prefix for the same vocabulary throughout the document. The Primer also permits prefix and vocab to be mixed. vocab supplies a default vocabulary for terms such as title, while a CURIE such as schema:articleBody selects a declared prefix.
How are CURIEs interpreted in RDFa attributes?
RDFa Core defines a CURIE as a prefix and a reference separated by :. The specification distinguishes CURIEs from full IRIs during attribute processing. Depending on the attribute, a value can allow terms, CURIEs and absolute IRIs, or CURIEs and IRIs. Square brackets force CURIE processing and cause invalid content to be ignored. After processing, the RDFa attributes that refer to IRIs are mapped to IRIs.
The same about value can therefore be written as a full IRI, a CURIE, or a safe CURIE:
<div about="http://dbpedia.org/resource/Albert_Einstein">...</div>
<div about="dbr:Albert_Einstein">...</div>
<div about="[dbr:Albert_Einstein]">...</div>
The brackets are significant in the third form. They are not part of the resulting IRI; they mark the value for the safe CURIE rules.
What should you check in a page?
Read each prefix value as pairs, then compare every CURIE used by property, typeof, rel, rev, about, resource, or datatype with the declaration that is in scope at that element. RDFa Core lists these attributes as accepting CURIEs or related IRI forms. Check the concatenated result, the element where the mapping was declared, and any closer declaration that could take precedence. If a value is bracketed, check that its contents form a valid CURIE under the same mapping.
Related terms
FAQ
Is dc:title a URL?
It is a CURIE in the RDFa markup. With dc mapped to http://purl.org/dc/terms/, an RDFa processor uses the resulting IRI http://purl.org/dc/terms/title.
Does a prefix declaration affect the whole document?
No. It applies from the declaring element through its descendants. A closer declaration for the same prefix takes precedence.
Should you use a different prefix name for each occurrence?
No. RDFa Core recommends using the same prefix for the same vocabulary throughout a document and notes that redefining mappings can cause confusion.
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