This document outlines an extension to the the syntax and processing rules that would allow the list of reserved words as well as CURIE prefixes recognized by RDFa to be extended. The goal of this mechanism is to make authoring RDFa easier for web developers and designers.

For those looking for an introduction to the use of RDFa and some real-world examples, please consult the RDFa Primer.

A sample test harness is available. This set of tests is not intended to be exhaustive. Users may find the tests to be useful examples of RDFa usage. An implementation report lists several implementations of this specification tested during the Candidate Recommendation period of RDFa. A community-maintained Wiki page includes subsequent updates.

Syntax Modifications

This section covers additional syntax that should be added to the RDFa [[!RDFA-SYNTAX]] language, more exactly to the RDFa 1.1. Core language to be defined by the RDFa Working Group.

The profile attribute

The profile attribute provides a mechanism to load one or more external RDFa vocabularies. The attribute’s value should contain one or more space-separated URIs. Each URI, when dereferenced and parsed, should provide RDF triples that that specify modifications to the current [evaluation context].

This specification makes use of the profile attribute . Although the profile attribute has been removed recentely from the HTML5 specification, there is a proposal to re-introduce it with a slightly different usage as in HTML4, namely by allowing profile on any HTML5 element. If that proposal is accepted by the HTML Working Group, then the usage of profile for RDFa vocabularies is justified. If that proposal is turned down, then the usage of profile might not be appropriate, and another attribute (e.g., vocab) should be used.

The RDFa Term Assignment Vocabulary

The RDFa Term Assignment Vocabulary is used to modify RDFa processing behavior. Its URI is http://www.w3.org/ns/rdfa#.

The Vocabulary contains the following term definition (shown here in Turtle format):

@prefix rdfa: <http://www.w3.org/ns/rdfa#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .

rdfa:term a rdf:Property ;
  rdfs:label "Term" ;
  rdfs:comment "Specifies a term (shortcut) for a URL, to be used in CURIE expansion." ;
  rdfs:range xsd:NMTOKEN .        
       
I hope the choice of xsd:NMTOKEN is the right one...

Processing Modifications

This section covers additions to the RDFa processing rules.

Processing Sequence Modifications

The profile attribute is processed after Step #1, but before Step #2 in Section 5.5: Sequence of [[!RDFA-SYNTAX]]. In other words, the profile attribute is always processed before xmlns: declarations are processed.

For every triple in each vocabulary document specified via the profile attribute that contains rdfa:term or rdfa:prefix as a predicate, create a mapping from the object literal to the subject and add it to the [local list of URI mappings]. If the object is not a Named Token, a mapping must not be created.

URIs specified via the profile attribute value are processed in order, from left to right. Any mapping conflicts, where an RDFa term is defined twice, are resolved by ensuring that the last mapping to be made is the one that is used by any process that utilizes the [local list of URI mappings]. This also means that mapping conflicts between URI mappings created via profile and URI mappings created via xmlns: are resolved by processing all profile attributes first and then processing all xmlns: attributes. The last duplicate URI mapping to be produced is always the value that will be stored in the [local list of URI mappings].

CURIE Processing Modification

CURIE processing changes slightly to allow colon-less and resource-less CURIEs. Therefore, a prefix-only CURIE, lacking both the colon and the resource, is allowed if a mapping for the prefix value exists in the [local list of URI mappings].

Syntax of Vocabulary Documents

The vocabulary definition must be defined either in RDFa or JSON. For a specific URI the server may serve both syntaxes and content negotiations should decide which version is requested, in which case the RDFa version takes priority. Vocabulary providers are not required to provide both.

It is an open issue whether JSON/JSONP should also be defined; the main motivation is to allow Javascript implementations to work in spite of the security issues. The current specification allows for both syntaxes, though the JSON/JSONP version might eventually prove to be unnecessary.

RDFa

The mapping terms can be defined using RDFa. The RDF triples are generated through the standard RDFa processing.

JSON/JSONP

Although not standardized, the Semantic Web community is experimenting with a JSON serialization of RDF, and this specification follows those community practices. The syntax for the terms is:

{
  URI-of-term :
    {
      "http://www.w3.org/ns/rdfa#term" : [ { "type" : "literal", "value" : term} ]
    }
}

Unfortunately, security considerations may make the usage of pure JSON encoding difficult, so JSONP should be used instead. The full encoding of the terms in JSOP would then be:

document.meta.addMappings({
  URI-of-term :
    {
      "http://www.w3.org/ns/rdfa#term" : [ { "type" : "literal", "value" : term} ]
    }
})
The final choice of the document.meta.addMappings term depends on the overall RDFa API specification.

Example

The mechanism described in this specification can be used both for the defintion of vocabulary prefixes as well as for the definition of individual terms.

Prefix definition

The following vocabulary file, residing at http://www.example.org/vocab-rdf-dc.html defines the standard RDF prefixes as well as the Dublin Core vocabulary prefix.

<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:rdfa="http://www.w3.org/2010/vocabs/rdfa">
  <head>
     ...
  </head>
  <body>
    <p>This is an example to defining the standard RDF and Dublin Core prefixes</p>

    <p about="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
       The <code property="rdfa:term">rdf</code> term can be used for the RDF vocabulary.
    </p>
    <p about="http://www.w3.org/2000/01/rdf-schema#">
       The <code property="rdfa:term">rdfs</code> term can be used for the RDFS vocabulary.
    </p>
    <p about="http://dublincore.org/documents/dcmi-terms/">
       The <code property="rdfa:term">dc</code> term can be used for the Dublin Core vocabulary.
    </p>
  </body>
</html>

Using the profile attribute, the following RDFa sniplet

<p about="http://www.example.org/doc" profile="http://www.example.org/vocab-rdf-dc">
  <span property="dc:title">title of the document</span>
  <span property="rdfs:comment">and this is a longer comment on the same document</span>
</p>

yields the following triples:

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dc: <http://dublincore.org/documents/dcmi-terms/> .
<http://www.example.org/doc>
  dc:title "title of the document" ;
  rdfs:comment "and this is a longer comment on the same document" .

The same vocabulary could be expressed by the http://www.example.org/vocab-rdf-dc.js JSONP file as follows:

document.meta.addMappings({
  "http://www.w3.org/1999/02/22-rdf-syntax-ns#" :
    {
      "http://www.w3.org/ns/rdfa#term" : [ { "type" : "literal", "value" : "rdf"} ]
    },
  "http://www.w3.org/2000/01/rdf-schema#" :
    {
      "http://www.w3.org/ns/rdfa#term" : [ { "type" : "literal", "value" : "rdfs"} ]
    },
  "http://dublincore.org/documents/dcmi-terms/" :
    {
      "http://www.w3.org/ns/rdfa#term" : [ { "type" : "literal", "value" : "dc"} ]
    }
})

Term definition

Given the following RDFa Vocabulary document at http://www.example.org/vocab-foaf-terms.html:

<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:rdfa="http://www.w3.org/ns/rdfa#">
  <head>
    <title>Example RDFa Vocabulary</title>
  </head>
  <body>
    <p>
      This is an example RDFa vocabulary that makes it easier to 
      use the foaf:name and foaf:homepage terms.
    </p>
    <p about="http://xmlns.com/foaf/0.1/name">
       The <code property="rdfa:term">name</code> term maps to foaf:name.
    </p>
    <p about="http://xmlns.com/foaf/0.1/homepage">
       The <code property="rdfa:term">homepage</code> term maps to foaf:homepage.
    </p>
  </body>
</html>
      

and the following HTML markup:

<div profile="http://www.example.org/vocab-foaf-terms" about="#me">
   My name is <span property="name">John Doe</span> and my blog is called
   <a rel="homepage" href="http://example.org/blog/">Understanding Semantics</a>.
</div>
      

The following triples should be generated:

@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> foaf:name "John Doe" ;
       foaf:homepage <http://example.org/blog/> .