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 references to 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 should be the subject of further discussion in the group; a possible decision might be to use another another attribute (e.g., vocab).

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:keyword a rdf:Property ;
  rdfs:label "Keyword" ;
  rdfs:comment "Specifies a term (shortcut) for a URL, to be used in CURIE expansion." ;
  rdfs:range xsd:NMTOKEN .        

rdfa:prefix a rdf:Property ;
  rdfs:label "Prefix" ;
  rdfs:comment "Specifies a CURIE prefix for a URL, to be used in CURIE expansion similarly to the xmlns:XXX usage." ;
  rdfs:range xsd:NMTOKEN .        
       
I hope the choice of xsd:NMTOKEN is the right one...

Processing Modifications

This section covers additions and modifications to the RDFa processing rules.

Processing Sequence Modifications

The Evaluation Context has one more element, called [keyword mappings]. It is treated similarly to the [URI Mappings]: it has a locally scoped value [local list keyword mappings]. This [local list of keyword mappings] is set to the value of [keyword mappings] as part of the initialization in Step #1. It is modified during the processing steps (see below) and is used to influence CURIE processing. Finally, similarly to URI mapping, the [keyword mapping] of the Evaluation Context is set to the value of [local list of keyword mapping] in Step #11.

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. The steps to be executed are as follows:

For every triple in each vocabulary document specified via the profile attribute that contains 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.

For every triple in each vocabulary document specified via the profile attribute that contains rdfa:keyword as a predicate, create a mapping from the object literal to the subject and add it to the [local list of keyword mapping]. 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 Syntax Modification

The CURIE Syntax Definition (section 7) should be modified to include keywords:

In normal evaluation of CURIEs the following context information would need to be provided:

  • a set of mappings from prefixes to URIs;
  • a mapping to use with the default prefix (for example, :p);
  • a mapping to use when there is no prefix (for example, p);
  • a mapping to use with the '_' prefix, which is used to generate unique identifiers (for example, _:p).

In RDFa these values are defined as follows:

  • the set of mappings from prefixes to URIs is provided by the current in-scope prefix declarations of the [current element] during parsing (i.e., [local list of URI mappings];
  • the mapping to use with the default prefix is the current default prefix mapping;
  • the mapping to use when there is no prefix is provided by the current in-scope keyword declarations of the [current element] during parsing (i.e., [local list of keyword mapping];
  • the mapping to use with the '_' prefix, is not explicitly stated, but since it is used to generate [bnode]s, its implementation needs to be compatible with the RDF definition.

A CURIE is a representation of a full URI. In the case of a CURIE without prefix, this URI is obtained by using the [local list of keyword mapping] to obtain the corresponding URI (if defined). In the case of a CURIE with prefix and reference, this URI is obtained by taking the currently in-scope mapping that is associated with prefix, and concatenating it with the reference. The resulting URI MUST be a syntactically valid IRI [[!IRI]]. For a more detailed explanation see CURIE and URI Processing. Note that while the lexical space of a CURIE is as defined in curie above, the value space is the set of IRIs.

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].

Other modifications

(Concentrating on the normative text only.)

Converting a CURIE to a URI

Section 5.4.2 should say:

Since a CURIE is merely a means for abbreviating a URI, its value is a URI, rather than the abbreviated form. Obtaining a URI from a CURIE involves the following steps:

  • If the CURIE includes a ':', ie, a prefix and a resource can be obtained, then:
    1. Split the CURIE at the colon to obtain the prefix and the resource.
    2. Using the prefix and the current in-scope mappings, obtain the URI that the prefix maps to.
    3. Concatenate the mapped URI with the resource value, to obtain an absolute URI.
  • Otherwise obtain the URI using the current in-scope mappings of keywords

Removal of the XHTML link type references

In the section on using CURIES in specific attributes (Section 5.4.4 the last bulleted item (referring to @rel and @rev) should be removed.

XHTML Metainformation module

This Section 9 will be broken out into a separate document anyway. The current section on special @rel and @rev values has to be reformulated by some sort of an XTML related default @profile value.

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 and especially 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, eg, the 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 is:

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

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#keyword" : [ { "type" : "literal", "value" : keyword} ]
    }
  URI-of-vocabulary :
    {
      "http://www.w3.org/ns/rdfa#prefix"  : [ { "type" : "literal", "value" : prefix} ]
    }
})
The final choice of the document.meta.addMappings term depends on the overall RDFa API specification.

Examples

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:prefix">rdf</code> prefix can be used for the RDF vocabulary.
    </p>
    <p about="http://www.w3.org/2000/01/rdf-schema#">
       The <code property="rdfa:prefix">rdfs</code> prefix can be used for the RDFS vocabulary.
    </p>
    <p about="http://dublincore.org/documents/dcmi-terms/">
       The <code property="rdfa:prefix">dc</code> prefix 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#prefix" : [ { "type" : "literal", "value" : "rdf"} ]
    },
  "http://www.w3.org/2000/01/rdf-schema#" :
    {
      "http://www.w3.org/ns/rdfa#prefix" : [ { "type" : "literal", "value" : "rdfs"} ]
    },
  "http://dublincore.org/documents/dcmi-terms/" :
    {
      "http://www.w3.org/ns/rdfa#prefix" : [ { "type" : "literal", "value" : "dc"} ]
    }
})

Keyword 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:keyword">name</code> term maps to foaf:name.
    </p>
    <p about="http://xmlns.com/foaf/0.1/homepage">
       The <code property="rdfa:keyword">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/> .