The current Web is primarily made up of an enormous number of documents that have been created using HTML. These documents contain significant amounts of structured data, which is largely unavailable to tools and applications. When publishers can express this data more completely, and when tools can read it, a new world of user functionality becomes available, letting users transfer structured data between applications and web sites, and allowing browsing applications to improve the user experience: an event on a web page can be directly imported into a user's desktop calendar; a license on a document can be detected so that users can be informed of their rights automatically; a photo's creator, camera setting information, resolution, location and topic can be published as easily as the original photo itself, enabling structured search and sharing.
RDFa Core is a specification for attributes to express structured data in any markup language. The embedded data already available in the markup language (e.g., HTML) can often be reused by the RDFa markup, so that publishers don't need to repeat significant data in the document content. The underlying abstract representation is RDF [[RDF11-PRIMER]], which lets publishers build their own vocabulary, extend others, and evolve their vocabulary with maximal interoperability over time. The expressed structure is closely tied to the data, so that rendered data can be copied and pasted along with its relevant structure.
The rules for interpreting the data are generic, so that there is no need for different rules for different formats; this allows authors and publishers of data to define their own formats without having to update software, register formats via a central authority, or worry that two formats may interfere with each other.
RDFa shares some of the same goals with microformats [[MICROFORMATS]]. Whereas microformats specify both a syntax for embedding structured data into HTML documents and a vocabulary of specific terms for each microformat, RDFa specifies only a syntax and relies on independent specification of terms (often called vocabularies or taxonomies) by others. RDFa allows terms from multiple independently-developed vocabularies to be freely intermixed and is designed such that the language can be parsed without knowledge of the specific vocabulary being used.
This document is a detailed syntax specification for RDFa, aimed at:
For those looking for an introduction to the use of RDFa and some real-world examples, please consult the [[RDFA-PRIMER]].
First, if you are not familiar with either RDFa or RDF, and simply want to add RDFa to your documents, then you may find the RDFa Primer [[RDFA-PRIMER]] to be a better introduction.
If you are already familiar with RDFa, and you want to examine the processing rules — perhaps to create an RDFa Processor — then you'll find the Processing Model section of most interest. It contains an overview of each of the processing steps, followed by more detailed sections, one for each rule.
If you are not familiar with RDFa, but you are familiar with RDF, then you might find reading the Syntax Overview useful, before looking at the Processing Model since it gives a range of examples of markup that use RDFa. Seeing some examples first should make reading the processing rules easier.
If you are not familiar with RDF, then you might want to take a look at the section on RDF Terminology before trying to do too much with RDFa. Although RDFa is designed to be easy to author — and authors don't need to understand RDF to use it — anyone writing applications that consume RDFa will need to understand RDF. There is a lot of material about RDF on the web, and a growing range of tools that support RDFa. This document only contains enough background on RDF to make the goals of RDFa more clear.
RDFa is a way of expressing RDF-style relationships using simple attributes in existing markup languages such as HTML. RDF is fully internationalized, and permits the use of Internationalized Resource Identifiers, or IRIs. You will see the term 'IRI' used throughout this specification. Even if you are not familiar with the term IRI, you probably have seen the term 'URI' or 'URL'. IRIs are an extension of URIs that permits the use of characters outside those of plain ASCII. RDF allows the use of these characters, and so does RDFa. This specification has been careful to use the correct term, IRI, to make it clear that this is the case.
Even though this specification exclusively
references IRIs, it is possible that a Host Language will
restrict the syntax for its attributes to a subset of IRIs
This is an Editorial Revision of the Recommendation published on the 22nd of August, 2013. That document was a revision of RDFa Syntax 1.0 [[RDFA-SYNTAX]]. There are a number of substantive differences between this version and Version 1.0, including:
There is a more thorough list of changes in Changes.
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.
RDF/XML [[RDF-SYNTAX-GRAMMAR]] provides sufficient flexibility to represent all of the abstract concepts in RDF. However, it presents a number of challenges; first it is difficult or impossible to validate documents that contain RDF/XML using XML Schemas or DTDs, which therefore makes it difficult to import RDF/XML into other markup languages. Whilst newer schema languages such as RELAX NG [[RELAXNG-SCHEMA]] do provide a way to validate documents that contain arbitrary RDF/XML, it will be a while before they gain wide support.
Second, even if one could add RDF/XML directly into an XML dialect like XHTML, there would be significant data duplication between the rendered data and the RDF/XML structured data. It would be far better to add RDF to a document without repeating the document's existing data. For example, an XHTML document that explicitly renders its author's name in the text — perhaps as a byline on a news site — should not need to repeat this name for the RDF expression of the same concept: it should be possible to supplement the existing markup in such a way that it can also be interpreted as RDF.
Another reason for aligning the rendered data with the structured data is that it is highly beneficial to express the web data's structure 'in context'; as users often want to transfer structured data from one application to another, sometimes to or from a non-web-based application, the user experience can be enhanced. For example, information about specific rendered data could be presented to the user via 'right-clicks' on an item of interest. Moreover, organizations that generate a lot of content (e.g., news outlets) find it easier to embed the semantic data inline than to maintain it separately.
In the past, many attributes were 'hard-wired' directly into the markup language to represent specific concepts. For example, in XHTML 1.1 [[XHTML11]] and HTML [[HTML401]] there is @cite; the attribute allows an author to add information to a document which is used to indicate the origin of a quote.
However, these 'hard-wired' attributes make it difficult to define a generic process for extracting metadata from any document since an RDFa Processor would need to know about each of the special attributes. One motivation for RDFa has been to devise a means by which documents can be augmented with metadata in a general, rather than hard-wired, manner. This has been achieved by creating a fixed set of attributes and parsing rules, but allowing those attributes to contain properties from any of a number of the growing range of available RDF vocabularies. In most cases the values of those properties are the information that is already in an author's document.
RDFa alleviates the pressure on markup language designers to anticipate all the structural requirements users of their language might have, by outlining a new syntax for RDF that relies only on attributes. By adhering to the concepts and rules in this specification, language designers can import RDFa into their environment with a minimum of hassle and be confident that semantic data will be extractable from their documents by conforming processors.
The following examples are intended to help readers who are not familiar with RDFa to quickly get a sense of how it works. For a more thorough introduction, please read the RDFa Primer [[RDFA-PRIMER]].
In RDF, it is common for people to shorten vocabulary terms via
abbreviated IRIs that use a 'prefix' and a 'reference'. This mechanism
is explained in detail in the section titled Compact URI Expressions.
The examples throughout this document assume that the following
In some of the examples below we have used IRIs with
fragment identifiers that are local to the document containing the RDFa
fragment identifiers shown (e.g., '
idiom, which is also used in RDF/XML [[!RDF-SYNTAX-GRAMMAR]] and other
RDF serializations, gives a simple way to 'mint' new IRIs for entities
described by RDFa and therefore contributes considerably to the
expressive power of RDFa. The precise meaning of IRIs which include
fragment identifiers when they appear in RDF graphs is given in
Section 7 of [[RDF-SYNTAX-GRAMMAR]]. To ensure that such fragment
identifiers can be interpreted correctly, media type registrations
for markup languages that incorporate RDFa should directly or
indirectly reference this specification.
RDFa makes use of a number of commonly found attributes, as well as
providing a few new ones. Attributes that already exist in widely
deployed languages (e.g., HTML) have the same meaning they always did,
although their syntax has been slightly modified in some cases. For
example, in (X)HTML there is no clear way to add new
In (X)HTML, authors can include metadata and relationships concerning
the current document by using the
elements (in these examples, XHTML+RDFa [[!XHTML-RDFA]] is used).
For example, the author of the page along with the pages
preceding and following the current page can be expressed using the
link and meta elements:
RDFa makes use of this concept, enhancing it with the ability to make use of other vocabularies by using full IRIs:
Because using full IRIs like those above can be cumbersome, RDFa also
permits the use of
RDFa supports the use of
Not only can IRIs in the document be re-used to provide metadata, but
so can inline text when used with
If some displayed text is different from the actual 'value' it
represents, a more precise value can be added using
RDFa allows the document to contain metadata information about other documents and resources:
In many cases a block of markup will contain a number of properties
that relate to the same item. It's possible with RDFa to indicate the
type of that item using
When dealing with small amounts of markup, it is sometimes easier to use full IRIs, rather than CURIEs. The previous example can also be written as follows:
A simple way of defining a portion of a document using terms from a
specific vocabulary is to use
The example above will produce the following triples, expressed here in Turtle syntax:
In simple cases the
The previous section gave examples of typical markup in order to illustrate the structure of RDFa markup. RDFa is short for "RDF in Attributes". In order to author RDFa you do not need to understand RDF, although it would certainly help. However, if you are building a system that consumes the RDF output of a language that supports RDFa you will almost certainly need to understand RDF. This section introduces the basic concepts and terminology of RDF. For a more thorough explanation of RDF, please refer to the RDF Concepts document [[RDF-SYNTAX-GRAMMAR]] and the RDF Syntax Document [[RDF-SYNTAX-GRAMMAR]].
The structured data that RDFa provides access to is a collection of statements. A statement is a basic unit of information that has been constructed in a specific format to make it easier to process. In turn, by breaking large sets of information down into a collection of statements, even very complex metadata can be processed using simple rules.
To illustrate, suppose we have the following set of facts:
This would be quite difficult for a machine to interpret, and it is certainly not in a format that could be passed from one data application to another. However, if we convert the information to a set of statements it begins to be more manageable. The same information could therefore be represented by the following shorter 'statements':
To make this information machine-processable, RDF defines a
structure for these statements. A statement is formally called a
The second part of a triple is the property of the subject that we want to define. In the examples here, the properties would be 'was born on', 'was born in', and 'has a picture at'. These properties are typically called predicates in RDF.
The final part of a triple is called the object. In the examples here the three objects have the values 'March 14, 1879', 'the German Empire', and 'http://en.wikipedia.org/wiki/Image:Albert_Einstein_Head.jpg'.
RDFa supports internationalized characters in the subject, 'predicate', and the object.
Breaking complex information into manageable units helps us be
specific about our data, but there is still some ambiguity. For
example, which 'Albert' are we talking about? If another system has
more facts about 'Albert', how could we know whether they are about
the same person, and so add them to the list of things we know about
that person? If we wanted to find people born in the German Empire,
how could we know that the predicate 'was born in' has the same
purpose as the predicate 'birthplace' that might exist in some other
system? RDF solves this problem by replacing our vague terms with
IRIs are most commonly used to identify web pages, but RDF makes use of them as a way to provide unique identifiers for concepts. For example, we could identify the subject of all of our statements (the first part of each triple) by using the DBPedia [http://dbpedia.org] IRI for Albert Einstein, instead of the ambiguous string 'Albert':
IRI references are also used to uniquely identify the objects in metadata statements (the third part of each triple). The picture of Einstein is already an IRI, but we could also use an IRI to uniquely identify the country 'German Empire'. At the same time we'll indicate that the name and date of birth really are literals (and not IRIs), by putting quotes around them:
IRI references are also used to ensure that predicates are unambiguous; now we can be sure that 'birthplace', 'place of birth', 'Lieu de naissance' and so on, all mean the same thing:
Although IRI resources are always used for subjects and predicates,
the object part of a triple can be either an IRI or a
A plain literal can also be given a language tag, to capture plain text in a natural language. For example, Einstein's birthplace has different names in English and German:
Some literals, such as dates and numbers, have very specific
meanings, so RDF provides a mechanism for indicating the type of a
RDF itself does not have one set way to express triples, since the key ideas of RDF are the triple and the use of IRIs, and not any particular syntax. However, there are a number of mechanisms for expressing triples, such as RDF/XML [[!RDF-SYNTAX-GRAMMAR]], Turtle [[TURTLE]], and of course RDFa. Many discussions of RDF make use of the Turtle syntax to explain their ideas, since it is quite compact. The examples we have just seen are already using this syntax, and we'll continue to use it throughout this document when we need to talk about the RDF that could be generated from some RDFa. Turtle allows long IRIs to be abbreviated by using an IRI mapping, which can be used to express a compact IRI expression as follows:
Here 'dbp:' has been mapped to the IRI for DBPedia and 'foaf:' has been mapped to the IRI for the 'Friend of a Friend' vocabulary.
Any IRI in Turtle could be abbreviated in this way. This means that we could also have used the same technique to abbreviate the identifier for Einstein, as well as the datatype indicator:
When writing examples, you will often see the following IRI in the Turtle representation:
This indicates the 'current document', i.e., the document being processed. In the end there will always be a full IRI based on the document's location, but this abbreviation serves to make examples more compact. Note in particular that the whole technique of abbreviation is merely a way to make examples more compact, and the actual triples generated would always use the full IRIs.
A collection of triples is called a graph. All of the
triples that are defined by this specification are contained in the
In order to allow for the compact expression of RDF statements, RDFa
allows the contraction of most
Note that CURIEs are only used in the markup and Turtle examples, and
will never appear in the generated
A growing use of embedded metadata is to take fragments of markup and move them from one document to another. This may happen through the use of tools, such as drag-and-drop in a browser, or through snippets of code provided to authors for inclusion in their documents. A good example of the latter is the licensing fragment provided by Creative Commons.
However, those involved in creating fragments (either by building tools, or authoring snippets), should be aware that this specification does not say how fragments are processed. Specifically, the processing of a fragment 'outside' of a complete document is undefined because RDFa processing is largely about context. Future versions of this or related specifications may do more to define this behavior.
Developers of tools that process fragments, or authors of fragments for manual inclusion, should also bear in mind what will happen to their fragment once it is included in a complete document. They should carefully consider the amount of 'context' information that will be needed in order to ensure a correct interpretation of their fragment.
The following is a brief description of RDFa in terms of the RDF terminology introduced here. It may be useful to readers with an RDF background:
In RDFa, a subject
This specification uses the term
A conforming RDFa Processor MAY make available additional triples
that have been generated using rules not described here, but these
triples MUST NOT be made available in the
A conforming RDFa Processor MUST preserve white space in both
A conforming RDFa Processor MUST examine the media type of a document
it is processing to determine the document's Host Language. If the
RDFa Processor is unable to determine the media type, or does not
support the media type, the RDFa Processor MUST process the document
as if it were media type
application/xml. See XML+RDFa
Document Conformance. A Host Language MAY specify additional
A conforming RDFa Processor MAY use additional mechanisms (e.g., the DOCTYPE, a file extension, the root element, an overriding user-defined parameter) to attempt to determine the Host Language if the media type is unavailable. These mechanisms are unspecified.
Host Languages that incorporate RDFa must adhere to the following:
For the avoidance of doubt, there is no requirement that attributes
). When a Host Language does not use the attributes in 'no namespace', they MUST be referenced via the XHTML Namespace (
This specification does not define a stand-alone document type. The
attributes herein are intended to be integrated into other host
languages (e.g., HTML+RDFa or XHTML+RDFa). However, this specification
does define processing rules for generic XML
documents - that is, those documents delivered as media types
application/xml. Such documents must meet all of the
It is possible that an XML grammar will have native attributes that conflict with attributes in this specification. This could result in an RDFa processor generating unexpected triples.
When an RDFa Processor processes an XML+RDFa document, it does so via
role), defined in
dc), defined in
This specification defines a number of attributes and the way in which the values of those attributes are to be interpreted when generating RDF triples. This section defines the attributes and the syntax of their values.
CDATAstring, for supplying machine-readable content for a literal (a 'literal object', in RDF terminology);
propertyattribute on the same element is to be added to the list for that predicate. The value of this attribute MUST be ignored. Presence of this attribute causes a list to be created if it does not already exist.
NCName ':' ' '+ xsd:anyURI
In all cases it is possible for these attributes to be used with
no value (e.g.,
The RDFa attributes play different roles in a semantically rich document. Briefly, those roles are:
Many attributes accept a white space separated list of tokens. This specification defines white space as:
whitespace ::= (#x20 | #x9 | #xD | #xA)+
When attributes accept a white space separated list of tokens, an RDFa Processor MUST ignore any leading or trailing white space.
This definition is consistent with the definition found in [[XML10]].
The working group is currently examining the productions for CURIE below in light of recent comments received from the RDF Working Group and members of the RDFa Working Group. It is possible that there will be minor changes to the production rules below in the near future, and that these changes will be backward incompatible. However, any such incompatibility will be limited to edge cases.
The key component of RDF is the IRI, but these are usually long and
unwieldy. RDFa therefore supports a mechanism by which IRIs can be
abbreviated, called 'compact URI expressions' or simply,
When expanded, the resulting IRI MUST be a syntactically valid IRI [[!RFC3987]]. For a more detailed explanation see CURIE and IRI Processing. The lexical space of a CURIE is as defined in curie below. The value space is the set of IRIs.
A CURIE is comprised of two components, a
:). In general use it is possible to
omit the prefix, and so create a CURIE that makes use of the 'default
prefix' mapping; in RDFa the 'default prefix' mapping is
It's also possible to omit both the prefix and the colon, and
so create a CURIE that contains just a reference which makes use of the
'no prefix' mapping. This specification does not define a 'no prefix'
mapping. RDFa Host Languages MUST NOT define a 'no prefix' mapping.
The RDFa 'default prefix' should not be confused with the 'default namespace' as defined in [[!XML-NAMES]]. An RDFa Processor MUST NOT treat an XML-NAMES 'default namespace' declaration as if it were setting the 'default prefix'.
The general syntax of a CURIE can be summarized as follows:
prefix ::= NCName reference ::= ( ipath-absolute / ipath-rootless / ipath-empty ) [ "?" iquery ] [ "#" ifragment ] (as defined in [[!RFC3987]]) curie ::= [ [ prefix ] ':' ] reference safe_curie ::= '[' [ [ prefix ] ':' ] reference ']'
safe_curie is not required,
even in situations where an attribute value is permitted to be a CURIE
or an IRI: An IRI that uses a scheme that is not an in-scope mapping cannot
be confused with a CURIE. The concept of a safe_curie is retained for
It is possible to define a CURIE prefix mapping in such a way that
it would overshadow a defined IRI scheme. For example, a document could map the prefix
'mailto' to 'http://www.example.com/addresses/'. Then a
In normal evaluation of CURIEs the following context information would need to be provided:
In RDFa these values are defined as follows:
A CURIE is a representation of a full IRI. The rules for determining that IRI are:
reference, the IRI is obtained by taking the current default prefix mapping and concatenating it with the
reference. If there is no current default prefix mapping, then this is not a valid CURIE and MUST be ignored.
reference, and if there is an in-scope mapping for
prefix(when compared case-insensitively), then the IRI is created by using that mapping, and concatenating it with the
prefix, then the value is not a CURIE.
See General Use of Terms in Attributes for the way items with no colon can be interpreted in some datatypes by RDFa Processors.
In many cases, language designers have attempted to use QNames for an extension mechanism [[XMLSCHEMA11-2]]. QNames do permit independent management of the name collection, and can map the names to a resource. Unfortunately, QNames are unsuitable in most cases because 1) the use of QName as identifiers in attribute values and element content is problematic as discussed in [[QNAMES]] and 2) the syntax of QNames is overly restrictive and does not allow all possible IRIs to be expressed.
A specific example of the problem this causes comes from attempting
to define the name collection for books. In a QName, the part after
the colon must be a valid element name, making an example such as the
This is not a valid QName simply because "0321154991" is not a valid element name. Yet, in the example given, we don't really want to define a valid element name anyway. The whole reason for using a QName was to reference an item in a private scope - that of ISBNs. Moreover, in this example, we want the names within that scope to map to an IRI that will reveal the meaning of that ISBN. As you can see, the definition of QNames and this (relatively common) use case are in conflict with one another.
This specification addresses the problem by defining CURIEs. Syntactically, CURIEs are a superset of QNames.
Note that this specification is targeted at language designers, not document authors. Any language designer considering the use of QNames as a way to represent IRIs or unique tokens should consider instead using CURIEs:
This section looks at a generic set of processing rules for creating a
set of triples that represent the structured data present in an RDFa
document. Processing need not follow the DOM traversal technique
outlined here, although the effect of following some other manner of
processing must be the same as if the processing outlined here were
followed. The processing model is explained using the idea of DOM
traversal which makes it easier to describe (particularly in relation to
Evaluating a document for RDFa triples is carried out by starting at the document object, and then visiting each of its child elements in turn, in document order, applying processing rules. Processing is recursive in that for each child element the processor also visits each of its child elements, and applies the same processing rules.
In some environments there will be little difference between starting at the root element of the document, and starting at the document object itself. It is defined this way because in some environments important information is present at the document object level which is not present on the root element.
As processing continues, rules are applied which may generate
triples, and may also change the
This specification does not say anything about what
should happen to the triples generated, or whether more triples might
be generated during processing than are outlined here. However, to be
conforming, an RDFa Processor MUST act as if at a minimum the rules in
this section are applied, and a single
During processing, each rule is applied using information provided
baseelement. The important thing is that it establishes an IRI against which relative paths can be resolved.
During the course of processing, new
During the course of processing a number of locally scoped values are needed, as follows:
rdf:typerelationships to types specified in
In this example we can see that an object resource ('German_Empire'), has become the subject for nested statements. This markup also illustrates the basic chaining pattern of 'A has a B has a C' (i.e., Einstein has a birth place of the German Empire, which has a long name of 'the German Empire').
It's also possible for the subject of nested statements to provide the object for containing statements — essentially the reverse of the example we have just seen. To illustrate, we'll take an example of the type of chaining just described, and show how it could be marked up more efficiently. To start, we mark up the fact that Albert Einstein had, at some point in his life, a residence both in the German Empire and in Switzerland:
Now, we show the same information, but this time we create an
In this example, the
Chaining can sometimes involve elements containing relatively
minimal markup, for example showing only one resource, or only one
predicate. Here the
img element is used to carry a
picture of Einstein:
When such minimal markup is used, any of the resource-related attributes could act as a subject or an object in the chaining:
Note that, as noted above, in many situations the
The subject for 'the German Empire' would remain Albert Einstein (and
that would, of course, be an error). This is the main difference
Since RDFa is ultimately a means for transporting RDF, a key concept
is the resource and its manifestation as an IRI. RDF deals
with complete IRIs (not relative paths); when converting RDFa to
triples, any relative IRIs MUST be resolved relative to the base IRI,
using the algorithm defined in section 6.5 of RFC 3987 [[!RFC3987]], Reference
Resolution. The values of RDFa attributes
that refer to IRIs use three different datatypes:
A consequence of this is that when the value of an attribute of this
datatype is the empty string (e.g.,
A related consequence of this is that when the value of an attribute of this datatype is an empty SafeCURIE (e.g.,
Note that it is possible for all values in an attribute to be ignored. When that happens, the attribute MUST be treated as if it were empty.
For example, the full IRI for Albert Einstein on DBPedia is:
This can be shortened by authors to make the information easier to
manage, using a CURIE. The first step is for the author to create a
prefix mapping that links a prefix to some leading segment of the IRI.
In RDFa these mappings are expressed using
Once the prefix has been established, an author can then use it to shorten an IRI as follows:
The author is free to split the IRI at any point. However, since a common use of CURIEs is to make available libraries of terms and values, the prefix will usually be mapped to some common segment that provides the most re-use, often provided by those who manage the library of terms. For example, since DBPedia contains an enormous list of resources, it is more efficient to create a prefix mapping that uses the base location of the resources:
CURIE prefix mappings are defined on the current element and its descendants. The inner-most mapping for a given prefix takes precedence. For example, the IRIs expressed by the following two CURIEs are different, despite the common prefix, because the prefix mappings are locally scoped:
In general it is a bad practice to redefine prefix mappings within a document. In particular, while it is permitted, mapping a prefix to different values at different places within a document could lead to confusion. The working group recommends that document authors use the same prefix to map to the same vocabulary throughout a document. Many vocabularies have recommended prefix names. The working group recommends that these names are used whenever possible.
There are a number of ways that attributes make use of CURIEs, and they need to be dealt with differently. These are:
An empty attribute value (e.g.,
is still a CURIE, and is processed as such. The rules
for this processing are defined in Sequence.
Specifically, however, an empty attribute value is never
treated as a relative IRI by this specification.
An example of an attribute that can contain a CURIEorIRI is
whilst to express the IRI above as a CURIE an author would do this:
The author could also use a safe CURIE, as follows:
Since non-CURIE values MUST be ignored, the following value in
However, this markup would set a subject, since it is not a CURIE, but a valid relative IRI:
Note that several RDFa attributes are able to also take
Some RDFa attributes have a datatype that permits a
term ::= NCNameStartChar termChar* termChar ::= ( NameChar - ':' ) | '/'
For the avoidance of doubt, this production means a 'term' in RDFa is an XML NCName that also permits slash as a non-leading character.
When an RDFa attribute permits the use of a term, and the value being evaluated matches the production for term above, it is transformed to an IRI using the following logic:
termmatches an item in the list of
termhas no associated IRI and MUST be ignored.
The general rules discussed in the previous sections apply to the RDFa attributes in the following ways:
Any value that matches a defined term MUST be expanded into a reference to the corresponding IRI. For example in the following examples:
would each generate the following triple:
In RDFa, it is possible to establish relationships using various
types of resource references, including
Consider the following example:
In the above fragment, two
RDFa Processors use, internally, implementation-dependent identifiers for bnodes. When triples are retrieved, new bnode indentifiers are used, which usually bear no relation to the original identifiers. However, implementations do ensure that these generated bnode identifiers are consistent: each bnode will have its own identifier, all references to a particular bnode will use the same identifier, and different bnodes will have different identifiers.
As a special case,
_: is also a valid reference for one
Processing would normally begin after the document to be parsed has
been completely loaded. However, there is no requirement for this to
be the case, and it is certainly possible to use a stream-based
approach, such as SAX [[SAX]] to extract the RDFa information.
However, if some approach other than the DOM traversal technique
defined here is used, it is important to ensure that Host
Language-specific processing rules are applied (e.g., XHTML+RDFa
[[!XHTML-RDFA]] indicates the
base element can be used,
base will affect the interpretation of IRIs in
link elements even if those elements are before the
element in the stream).
In this section the term 'resource' is used to mean '
At the beginning of processing, an initial
Processing begins by applying the processing rules below to the
document object, in the context of this initial
This specification defines processing rules for optional
attributes that may not be present in all Host Languages (e.g.,
The processing rules are:
If no resource is provided then the first match from the following rules will apply:
Note that final value of the
XMLLiteralin the vocabulary
The actual literal is either the value of
The actual literal is either the value of
XMLLiteralin the vocabulary
The value of the
XMLLiteral in the vocabulary
The format of the resulting serialized content is as defined
in Exclusive XML Canonicalization Version 1.0 [[XML-EXC-C14N]].
In order to maintain maximum portability of this literal, any children of the current node that are elements MUST have the current XML namespace declarations (if any) declared on the serialized element. Since the child element node could also declare new XML namespaces, the RDFa Processor MUST be careful to merge these together when generating the serialized element definition. For avoidance of doubt, any re-declarations on the child node MUST take precedence over declarations that were active on the current node.
Additionally, if there is a value for
The processing rules covered in the previous section are designed to
extract as many triples as possible from a document. The RDFa
Processor is designed to continue processing, even in the event of
errors. For example, failing to resolve a prefix mapping or
If an RDFa Processor supports the generation of a
rdfa:ErrorMUST be generated when the document fails to be fully processed as a result of non-conformant Host Language markup.
rdfa:WarningMUST be generated when a CURIE prefix fails to be resolved.
rdfa:WarningMUST be generated when a Term fails to be resolved.
rdfa:Error triples MAY be generated by the RDFa Processor.
SAX-based processors or processors that utilize function or method
callbacks to report the generation of triples are classified as
query parameter MUST be used to specify the value. The allowable
processor or both
values, in any order, separated by a comma character.
If the graph preference is not specified, the
To ensure interoperability, a core hierarchy of classes is defined for the content of the processor graph. Separate errors or warnings are resources (typically blank nodes) of a specific type, with additional properties giving more details on the error condition or the warning. This specification defines only the top level classes and the ones referring to the error and warning conditions defined explicitly by this document. Other, implementation-specific subclasses may be defined by the RDFa Processor.
The top level classes are
rdfa:Info, defined as part of the RDFa
Vocabulary. Furthermore, a single property is defined on those
rdfa:context, that provides an extra
context for the error, e.g., http response, an XPath information, or
simply the IRI to the RDFa resource. Usage of this property is
optional, and more than one triple can be used with this predicate
on the same subject. Finally, error and warning instances SHOULD use
dc:description should provide a short,
human readable but implementation dependent description of the
dc:date should give the time when the error was
found and it is advised to be as precise as possible to allow the
detection of, for example, possible network errors.
The example below shows the triples that should be minimally
present in the processor graph as a result of an error (the content
of the literal for the
dc:description predicate is
A slightly more elaborate example makes use of the
property to provide further information, using external vocabularies
to represent HTTP headers or XPointer information (note that a
processor may not have these information in all cases, i.e., these
information are not required):
Processors MAY perform vocabulary expansion by utilizing limited RDFS and OWL entailment rules, as described in RDFa Vocabulary Expansion.
This section provides an in-depth examination of the processing steps described in the previous section. It also includes examples which may help clarify some of the steps involved.
The key to processing is that a triple is generated whenever a
predicate/object combination is detected. The actual triple generated
will include a subject that may have been set previously, so this is
tracked in the current
The attributes for setting a predicate are
There are many examples in this section. The examples are all written using XHTML+RDFa. However, the explanations are relevant regardless of the Host Language.
When triples are created they will always be in relation to a
subject resource which is provided either by
When parsing begins, the
in (X)HTML). This means that by default any metadata found in the
document will concern the document itself:
This would generate the following triples:
It is possible for the data to appear elsewhere in the document:
which would still generate the triple:
In (X)HTML the value of
base may change the initial
An RDFa Processor should now generate the following triples, regardless of the IRI from which the document is served:
As processing progresses, any
become part of a new calendar event object, rather than referring
to the document as they do in the head of the document:
With this markup an RDFa Processor will generate the following triples:
Other kinds of resources can be used to set the
This should generate the following triples:
Similarly, authors may make statements about images:
which should generate the following triple:
rdf:type, which means that the
processor only requires the value of the type. The
question is: which resource gets these typing information?
If the element has an
also creates the triple:
the generated triples also include:
This markup would cause a
foaf:Person, as well as name
and given name properties:
This usage of “isolated”
_:aas being distinct from
_:b. But by not exposing these values to any external software, it is possible to have complete control over the identifier, as well as preventing further statements being made about the item.
As emphasized in the section on chaining,
one of the main differences between
generating the same triples as before. Here again, a
As described in the previous two sections,
But if neither
The most usual way that an inherited subject might get set would be when the parent statement has an object that is a resource. Returning to the earlier example, in which the long name for the German_Empire was added, the following markup was used:
In an earlier illustration the subject and object for the
German Empire were connected by removing the
but it is also possible for authors to achieve the same effect
by removing the
In this situation, all statements that are 'contained' by the
object resource representing the German Empire (the value in
Looking at the triples that an RDFa Processor would generate,
we can see that we actually have two groups of statements; the
first group is set to refer to the
while the second group refers to the
Note also that the same principle described here applies to
There will be occasions when the author wants to connect the subject and object as shown above, but is not concerned to name the resource that is common to the two statements (i.e., the object of the first statement, which is the subject of the second). For example, to indicate that Einstein was influenced by Spinoza the following markup could well be used:
An RDFa Processor will generate the following triples:
However, an author could just as easily say that Spinoza influenced something by the name of Albert Einstein, that was born on March 14th, 1879:
In RDF terms, the item that 'represents' Einstein is anonymous,
since it has no IRI to identify it. However, the item is given
an automatically generated
An RDFa Processor will generate the following triples:
Note that the
div is superfluous, and an RDFa
Processor will create the intermediate object even if the
element is removed:
An alternative pattern is to keep the
and move the
From the point of view of the markup, this latter layout is to be preferred, since it draws attention to the 'hanging rel'. But from the point of view of an RDFa Processor, all of these permutations need to be supported.
When a new subject is calculated, it is also used to complete any incomplete triples that are pending. This situation arises when the author wants to 'chain' a number of statements together. For example, an author could have a statement that Albert Einstein was born in the German Empire:
and then a further statement that the 'long name' for this country is the German Empire:
RDFa allows authors to insert this statement as a self-contained unit into other contexts:
But it also allows authors to avoid unnecessary repetition and to 'normalize' out duplicate identifiers, in this case the one for the German Empire:
When this happens the
Then as processing continues, the RDFa Processor encounters the subject of the statement about the long name for the German Empire, and this is used in two ways. First it is used to complete the 'incomplete triple':
and second it is used to generate its own triple:
Note that each occurrence of
In this example there is one incomplete triple:
When the processor meets each of the
These examples show how
First the following incomplete triple is stored:
Then when the RDFa Processor processes the two occurrences of
Triples are also 'completed' if any one of
This example has two 'hanging rels', and so two situations when 'incomplete triples' will be created. Processing would proceed as follows; first an incomplete triple is stored:
Next, the RDFa Processor processes the predicate values for
note that only the first needs to 'complete' the 'hanging rel'. So
foaf:name generates two triples:
dbp:dateOfBirth generates only one:
dbp-owl:residence also uses the same
As before, the two occurrences of
The entire set of triples that an RDFa Processor should generate is as follows:
Although objects have been discussed in the previous sections, as part of the explanation of subject resolution, chaining, evaluation contexts, and so on, this section will look at objects in more detail.
There are two types of object,
Both of these examples give the following triple:
The value of
In RDFa the Host Language may provide a mechanism for setting
the language tag. In XHTML+RDFa [[!XHTML-RDFA]], for example,
the XML language attribute @xml:lang
or the attribute @lang is used to add
this information, whether the plain literal is designated by
Note that the language value can be inherited as defined in [[!XML10-4e]], so the following syntax will give the same triple as above:
Literals can be given a data type using
This can be represented in RDFa as follows:
The triple that this markup generates includes the datatype after the literal:
XML documents cannot contain XML markup in their attributes,
which means it is not possible to represent XML within
RDFa therefore supports the use of arbitrary markup to express XML
literals by using
This would generate the following triple, with the XML preserved in the literal:
This requires that an IRI mapping for the prefix
has been defined.
In the examples given here the
sup element is
actually part of the meaning of the literal, but there will be
situations where the extra markup means nothing, and can therefore
be ignored. In this situation omitting the
Rendering of this page has highlighted the term the
user searched for. Setting
The value of this
Most of the rules governing the processing of objects that are resources are to be found in the processing descriptions given above, since they are important for establishing the subject. This section aims to highlight general concepts, and anything that might have been missed.
One or more
RDFa provides the
blockquote element generates the following
Note that, in the example above,
When a predicate has been expressed using
It's also possible to use both
which then yields two triples:
When a triple predicate has been expressed using
This process is described in more detail in Completing 'Incomplete Triples'.
An RDF graph is a collection of triples. This also means that if the graph contains two triples sharing the same subject and predicate:
There is no way for an application to rely on the relative order of the two triples when, for example, querying a database containing these triples. For most of the applications and data sets this is not a problem, but, in some cases, the order is important. A typical case is publications: when a book or an article has several co-authors, the order of the authors may be important.
RDF has a set of predefined predicates that have an agreed-upon semantic of order. For example, the publication: "Semantic Annotation and Retrieval, by Ben Adida, Mark Birbeck, and Ivan Herman" could be described in RDF triples using these terms as follows:
which conveys the notion of 'order' for the three authors. Admittedly, this is not very readable. However, Turtle has a syntactic shorthand for these structures:
It would of course be possible to reproduce the same structure in
RDFa, using the RDF predicates
as well as the special resource
rdf:nil. However, to
make this easier, RDFa provides the
Note that the order in the list is determined by the document order.
(The value of the
Lists may also include IRIs and not only literals. For example, two of the three co-authors could decide to publicise their FOAF address in the authors’ list:
In the example above,
Incomplete Triples can also be used in conjunction with lists when all list elements are resources and not literals. For example, the previous example, this time with all three authors referring to their FOAF profile, could have been written as:
Note that it is also possible to express an empty list,
RDFa permits Host Languages to define an
rdfa:uri, create a key-value mapping from the
rdfa:prefixobject literal (the key) to the
rdfa:uriobject literal (the value). Add this mapping to the
rdfa:uri, create a key-value mapping from the
rdfa:termobject literal (the key) to the
rdfa:uriobject literal (the value). Add this mapping to the
rdfa:vocabulary, define the
When an RDFa Initial Context is defined using an RDF serialization, it MUST use the vocabulary terms above to declare the components of the context.
Caching of the relevant triples retrieved via this mechanism is RECOMMENDED. Embedding definitions for well known, stable RDFa Initial Contexts in the implementation is RECOMMENDED.
rdfa:uripredicate MUST be an absolute IRI.
rdfa:termpredicate MUST match the production for term.
rdfa:prefixpredicate must match the production for prefix.
rdfa:vocabularypredicate MUST be an absolute IRI.
rdfa:vocabularypredicate, or if there are additional
rdfa:termpredicates sharing the same subject, an RDFa Processor MUST NOT create the associated mapping.
Since RDFa is based on RDF, the semantics of RDF vocabularies can be used to gain more knowledge about data. Vocabularies, properties and classes are identified by IRIs, which enables them to be discoverable. RDF data published at the location of these IRIs can be retrieved, and descriptions of the properties and classes using specified semantics can be applied.
RDFa Vocabulary Expansion is an optional processing step which may be
added once the normal processing steps described in Processing
Model are complete. Vocabulary expansion relies on a very small
sub-set of OWL entailment [[!OWL2-OVERVIEW]] to add triples to the
It can be very useful to make generalized data available for
subsequent usage of RDFa-embedded data by expanding inferred statements
entailed by these semantics. This provides for existing vocabularies
that extend well-known vocabularies to have those properties added to
the output graph automatically. For example, the namespace document of
the Creative Commons vocabulary, i.e.,
cc:license to be a sub-property of
By using the
which results in the following
After vocabulary expansion, the
Other vocabularies, specifically intended to provide relations to multiple vocabularies, could also be defined by publishers, allowing use of terms in a single namespace which result in properties and/or classes from other primary vocabularies being imported. This benefits publishers as data is now more widely searchable and encourages the practice of referencing well-known vocabularies.
rdfa:usesVocabulary is dereferenced.
If the dereferencing yields the serialization of an RDF
graph, that serialization is parsed and the resulting graph is merged
with the vocabulary graph. (An RDFa processor capable of vocabulary
expansion MUST accept an RDF graph serialized in RDFa, and SHOULD
accept other standard serialization formats of RDF such as RDF/XML
[[!RDF-SYNTAX-GRAMMAR]] and Turtle [[TURTLE]].)
Note that if, in the second step, a particular vocabulary is serialized in RDFa, that particular graph is not expected to undergo any vocabulary expansion on its own.
Vocabulary expansion is then performed as follows:
For the purpose of vocabulary processing, RDFa used a very restricted subset of the OWL vocabulary and is based on the RDF-Based Semantics of OWL [[!OWL2-RDF-BASED-SEMANTICS]]. The RDFa Vocabulary Entailment uses the following terms:
RDFa Vocabulary Entailment considers only the entailment on individuals
(i.e., not on the relationships that can be deduced on the
properties or the classes themselves.)
While the formal definition of the RDFa Entailment
refers to the general OWL 2 Semantics, practical implementations may
rely on a subset of the OWL 2 RL Profile’s entailment expressed in
4.3 of [[!OWL2-PROFILES]]). The
relevant rules are, using the rule identifications in section
4.3 of [[!OWL2-PROFILES]]):
The entailment described in this section is the minimum
useful level for RDFa. Processors may, of course, choose to follow
more powerful entailment regimes, e.g., include full RDFS [[!RDF11-MT]]
or OWL [[!OWL2-OVERVIEW]] entailments. Using those entailments
applications may perform datatype validation by checking
of a property, or use the advanced facilities offered by, e.g., OWL’s
property chains to interlink vocabularies further.
Conforming RDFa processors are not required to provide vocabulary expansion.
If an RDFa processor provides vocabulary expansion, it MUST NOT be
performed by default. Instead, the processor MUST provide an option,
which, when used, instructs the RDFa processor to perform a vocabulary
expansion before returning the output graph.
Although vocabulary expansion is described in terms of
For RDFa Processors caching the relevant graphs retrieved via this mechanism is RECOMMENDED. Caching is usually based on HTTP response headers like expiration time, cache control, etc.
For publishers of vocabularies, the IRI for the vocabularies SHOULD be dereferenceable, and should return an RDF graph with the vocabulary description. This vocabulary description SHOULD be available encoded in RDFa, and MAY also be available in other RDF serialization syntaxes (using content negotiation to choose among the different formats). If possible, vocabulary descriptions SHOULD include subproperty and subclass statements linking the vocabulary terms to other, well-known vocabularies. Finally, HTTP responses SHOULD include fields usable for cache control, e.g., expiration date.
In order to facilitate the use of CURIEs in markup languages, this
specification defines some additional datatypes in the XHTML datatype
languages that want to import these definitions can find them in the
"datatypes" file for their schema grammar:
Specifically, the following datatypes are defined:
The following informative XML Schema definition for these datatypes is included as an example:
The following informative XML DTD definition for these datatypes is included as an example:
The RDFa Vocabulary has three roles: it contains the predicates to
define the terms and prefixes in
http://www.w3.org/ns/rdfa#; the usual prefix
used in this document is
This vocabulary specification is available in XHTML+RDFa 1.1, Turtle, and in RDF/XML formats.
The RDFa Vocabulary includes the following triples (shown here in Turtle [[TURTLE]] format):
These predicates can be used to define the
These predicates are used to 'pair' IRI strings and their usage in the form of a prefix and/or a term as part of, for example, a blank node. An example can be as follows:
which defines a prefix for the FOAF IRI.
The Vocabulary includes the following term definitions (shown here in Turtle [[TURTLE]] format):
The Vocabulary includes the following term definitions (shown here in Turtle [[TURTLE]] format):
This specification introduces a number of new features, and extends the behavior of some features from the previous version. The following summary may be helpful to RDFa Processor developers, but is not meant to be comprehensive.
While this specification strives to be as backward compatible as possible with [[RDFA-SYNTAX]], the changes above mean that there are some circumstances where it is possible for different RDF triples to be output for the same document when processed by an RDFa 1.0 processor vs. an RDFa 1.1 processor. In order to minimize these differences, a document author can do the following:
XHTML+RDFa 1.0on the
When producing XHTML+RDFa 1.1 documents, it is possible to reduce the incompatibilities with RDFa 1.0 conforming processors by doing the following:
XHTML+RDFa 1.0on the
At the time of publication, the active members of the RDFa Working Group were: