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 syntaxes 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 attributes provides references to one or more “profile files”. These profile files may define:

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], using the RDFa Term Assignment Vocabulary, defined below.

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.

The vocab attribute

The vocab attribute provides an alternative to the keyword definition mechanism provided by the profile attribute. It provides a default URI that can be used to be concatenated to any keyword that is not otherwise defined (via a profile document).

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 includes the following term definition (shown here in Turtle [[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:uri a rdf:Property .
  rdfs:range xsd:anyURI ;
  rdfs:domain rdfa:VocabularyMapping .
	
rdfa:prefix a rdf:Property .
  rdfs:range xsd:NMTOKEN ;
  rdfs:domain rdfs:PrefixMapping .

rdfa:keyword a rdf:Property .
  rdfs:range xsd:NMTOKEN ;
  rdfs:domain rdfs:PrefixMapping .

A more complete definition of the vocabulary can be found in separate vocabulary file in Turtle format.

These predicates can be used to “pair” URI strings and their usage in the form of a prefix and/or a keyword as part of, eg, a blank node. An example can be as follows:

[
  rdfa:uri     "http://xmlns.com/foaf/0.1/name" ;
  rdfa:prefix  "foaf" 
]

which defines a prefix for the foaf URI.

An RDFa and an RDF/XML versions of the vocabulary should be provided, too
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 two more elements. Namely:

Default Keyword URI

The [default keyword URI] is part of the Evaluation Context. It has a locall scoped value [local default keyword URI]; this set to the value of [default keyword URI] as part of the initialization in Step #1. If the node has a vocab attribute, than the value of the attribute overrides the (inherited) value for the [local default keyword URI]. Finally, the Evaluation Context is set to the value of [local default keyword URI] in Step #11.

Keyword mappings, and the evaluation of the profile attribute

The [keyword mappings] is part of the Evaluation Context. 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 resource in each vocabulary document specified via the profile attribute that is the common subject of an rdfa:prefix and an rdfa:uri predicate, create a mapping from the object literal of the rdfa:prefix predicate to the object literal of the rdfa:uri predicate, and add it to the [local list of URI mappings]. If one of the objects is not a Literal or if there are additional rdfa:uri or rdfa:prefix predicates sharing the same subject, no mapping is created.

For every resource in each vocabulary document specified via the profile attribute that is the common subject of an rdfa:keyword and an rdfa:uri predicate, create a mapping from the object literal of the rdfa:keyword predicate to the object literal of the rdfa:uri predicate, and add it to the [local list of keyword mapping]. If one of the objects is not a Literal or if there are additional rdfa:uri or rdfa:keyword predicates sharing the same subject, no mapping is created.

Note that both keyword and prefix mapping are case-insensitive, ie, the values of rdfa:prefix and of rdfa:keyword are, conceptually, converted to their lower case equivalent before added to the local list of URI and keyword mappings.

In case RDFa1.1 defines some sort of an error reporting mechanism, then failing the conditions above should also yield an error and/or a warning.

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] and the [local default keyword URI])
  • 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); if that mapping is not defined, but the [local default keyword URI] is, then the URI is obtained by concatenating the value of [local default keyword URI] and the CURIE.
  • 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]].

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 can be defined in any valid RDF serialization syntax, like RDF/XML [[!RDF-SYNTAX-GRAMMAR]], Turtle [[TURTLE]], or indeed RDFa [[!RDFA-SYNTAX]]. Comforming RDFa processors are MUST understand RDFa; they MAY understand other serializations formats.

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.

Default keyword URI

A simple way of defining a portion of the code to use FOAF terms is to use the vocab attribute to define a default keyword URI, ie, the vocab attribute:

<div vocab="http://xmlns.com/foaf/0.1/" 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 will be generated:

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

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 in RDFa.

<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:rdfa="http://www.w3.org/ns/rdfa#">
  <head>
     ...
  </head>
  <body>
    <p>This is an example to defining the standard RDF and Dublin Core prefixes</p>
    
    <p typeof="rdfa:PrefixMapping">The "<span property="rdfa:prefix">rdf</span>" prefix can be used
    for the URI: "<span property="rdfa:uri">http://www.w3.org/1999/02/22-rdf-syntax-ns#</span>.</p>
    
    <p typeof="_:a">The "<span property="rdfa:prefix">rdfs</span>" prefix can be used
    for the URI: "<span property="rdfa:uri">http://www.w3.org/2000/01/rdf-schema#</span>.</p>
    
    <p typeof="rdfa:PrefixMapping">The "<span property="rdfa:prefix">dc</span>" prefix can be used
    for the URI: "<span property="rdfa:uri">http://dublincore.org/documents/dcmi-terms/</span>.</p>
</html>

(Note that typing the blank node with rdfa:PrefixMapping is not necessary, as shown by the association of the rdfs.)

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 more succintly in Turtle:

          @prefix rdfa: <http://www.w3.org/ns/rdfa#> .
[ rdfa:uri "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
  rdfa:prefix "rdf"
]
[ rdfa:uri "http://www.w3.org/2000/01/rdf-schema#";
  rdfa:prefix "rdfs"
]
[ rdfa:uri "http://dublincore.org/documents/dcmi-terms/";
  rdfa:prefix "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 typeof="_:a">The "<span property="rdfa:keyword">name</span>" keyword can be used
    for the URI: "<span property="rdfa:uri">http://xmlns.com/foaf/0.1/name</span>.</p>
    <p typeof="_:a">The "<span property="rdfa:keyword">homepage</span>" keyword can be used
    for the URI: "<span property="rdfa:uri">http://xmlns.com/foaf/0.1/homepage</span>.</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 will be generated:

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