index.html
37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>RDFa Primer </title><style type="text/css">
code { font-family: monospace; }
div.constraint,
div.issue,
div.note,
div.notice { margin-left: 2em; }
dt.label { display: run-in; }
li p { margin-top: 0.3em;
margin-bottom: 0.3em; }
div.exampleInner pre { margin-left: 1em;
margin-top: 0em; margin-bottom: 0em}
div.exampleOuter {border: 4px double gray;
margin: 0em; padding: 0em}
div.exampleInner { background-color: #d5dee3;
border-top-width: 4px;
border-top-style: double;
border-top-color: #d3d3d3;
border-bottom-width: 4px;
border-bottom-style: double;
border-bottom-color: #d3d3d3;
padding: 4px; margin: 0em }
div.exampleWrapper { margin: 4px }
div.exampleHeader { font-weight: bold;
margin: 4px}
.xmlverb-default { color: #333333; background-color: #ffffff; font-family: monospace }
.xmlverb-element-name { color: #990000 }
.xmlverb-element-nsprefix { color: #666600 }
.xmlverb-attr-name { color: #660000 }
.xmlverb-attr-content { color: #000099; font-weight: bold }
.xmlverb-ns-name { color: #666600 }
.xmlverb-ns-uri { color: #330099 }
.xmlverb-text { color: #000000; font-weight: bold }
.xmlverb-comment { color: #006600; font-style: italic }
.xmlverb-pi-name { color: #006600; font-style: italic }
.xmlverb-pi-content { color: #006666; font-style: italic }
</style><link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-WG-NOTE"></head><body><div class="head"><p><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" alt="W3C" height="48" width="72"></a></p>
<h1><a name="title" id="title"></a>RDFa Primer </h1>
<h2><a name="subtitle" id="subtitle"></a>Bridging the Human and Data Webs</h2>
<h2><a name="w3c-doctype" id="w3c-doctype"></a>W3C Working Group Note 14 October 2008</h2><dl><dt>This version:</dt><dd>
<a href="http://www.w3.org/TR/2008/NOTE-xhtml-rdfa-primer-20081014/">http://www.w3.org/TR/2008/NOTE-xhtml-rdfa-primer-20081014/</a></dd><dt>Latest version:</dt><dd>
<a href="http://www.w3.org/TR/xhtml-rdfa-primer/">http://www.w3.org/TR/xhtml-rdfa-primer/</a>
</dd><dt>Previous version:</dt><dd>
<a href="http://www.w3.org/TR/2008/WD-xhtml-rdfa-primer-20080620/">http://www.w3.org/TR/2008/WD-xhtml-rdfa-primer-20080620/</a>
</dd><dt>Editors:</dt><dd>Ben Adida, Creative Commons <a href="mailto:ben@adida.net"><ben@adida.net></a></dd><dd>Mark Birbeck, webBackplane <a href="mailto:mark.birbeck@webBackplane.com"><mark.birbeck@webBackplane.com></a></dd></dl>
<p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2008 <a href="http://www.w3.org/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>, <a href="http://www.ercim.org/"><acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p>
</div><hr><div>
<h2><a name="abstract" id="abstract"></a>Abstract</h2><p>
Today's web is built predominantly for human consumption. Even as machine-readable data begins to appear on the web, it is typically distributed in a separate file, with a separate format, and very limited correspondence between the human and machine versions. As a result, web browsers can provide only minimal assistance to humans in parsing and processing web data: browsers only see presentation information. We introduce RDFa, which provides a set of XHTML attributes to augment visual data with machine-readable hints. We show how to express simple and more complex datasets using RDFa, and in particular how to turn the existing human-visible text and links into machine-readable data without repeating content.
</p><p>
This document provides only a Primer to RDFa. The normative specification of RDFa can be found in <a href="#RDFA-SYNTAX">[RDFA-SYNTAX]</a>.
</p></div><div>
<h2><a name="status" id="status"></a>Status of This Document</h2>
<p><em>This section describes the status of this document at the
time of its publication. Other documents may supersede this
document. A list of current W3C publications and the latest
revision of this technical report can be found in the <a
href="http://www.w3.org/TR/">W3C technical reports index</a> at
http://www.w3.org/TR/.</em></p>
<p>This document is a Working Group Note produced jointly by the W3C <a
href="http://www.w3.org/2006/07/SWD/">Semantic Web
Deployment Working Group</a> [<a href="#SWD-WG">SWD-WG</a>] and
the W3C <a
href="http://www.w3.org/MarkUp/">XHTML2 Working Group</a>
[<a href="#XHTML2-WG">XHTML2-WG</a>].
This work is part of both the <a
href="http://www.w3.org/2001/sw/">W3C Semantic Web
Activity</a> and the <a href="http://www.w3.org/MarkUp/">HTML
Activity</a>. The transition of this document to Working Group Note
occurs simultaneously with the transition of the
RDFa syntax specification to W3C Recommendation.</p>
<p>This version of the RDFa Primer contains small editorial
changes to the previous version as well as a short additional
section (<a href="#id85429">4.1</a>) providing pointers to
those wishing to create new
relationship vocabularies. The changes are detailed
in a <a href="diff">differences document</a>. The Working Groups
have received suggestions that this document be expanded and
the Groups may add to it in the future but are not committing
to do so.</p>
<p>Comments on this Working Group Note are welcome and may be sent to
<a href="mailto:public-rdf-in-xhtml-tf@w3.org"
>public-rdf-in-xhtml-tf@w3.org</a>; please include
the text "comment" in the subject line. All messages received at
this address are viewable in a
<a href="http://lists.w3.org/Archives/Public/public-rdf-in-xhtml-tf/"
>public archive</a>.</p>
<p>Publication as a Working Group Note does not imply endorsement by
the W3C Membership. This is a draft document and may be updated,
replaced or obsoleted by other documents at any time. It is
inappropriate to cite this document as other than work in
progress.</p>
<p>This document was produced groups operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>. W3C maintains a <a rel="disclosure"
href="http://www.w3.org/2004/01/pp-impl/32107/status">public list of any patent disclosures</a> made in connection with the deliverables of the XHTML 2 group and another <a rel="disclosure" href="http://www.w3.org/2004/01/pp-impl/39408/status">public list of any patent disclosures</a> made in connection with the deliverables of the Semantic Web Deployment Working Group; those pages also
include instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.</p>
</div><div class="toc">
<h2><a name="contents" id="contents"></a>Table of Contents</h2><p class="toc">1 <a href="#id84428">Introduction</a><br> 1.1 <a href="#id84480">HTML vs. XHTML</a><br>2 <a href="#id84491">Adding Flavor to XHTML</a><br> 2.1 <a href="#id84514">Licensing your Work</a><br> 2.2 <a href="#id84624">Labeling the Title and Author</a><br> 2.3 <a href="#id84801">Multiple Items per Page</a><br>3 <a href="#id84945">Going Deeper</a><br> 3.1 <a href="#id84953">Contact Information</a><br> 3.2 <a href="#id85076">Social Network</a><br>4 <a href="#id85315">You Said Something about RDF?</a><br> 4.1 <a href="#id85429">Custom Vocabularies</a><br>5 <a href="#id85510">Find Out More</a><br>6 <a href="#id85528">Acknowledgments</a><br>7 <a href="#id85538">Bibliography</a><br></p></div><hr><div class="body"><div class="div1">
<h2><a name="id84428" id="id84428"></a>1 Introduction</h2><p>
The web is a rich, distributed repository of interconnected information organized primarily for human consumption. On a typical web page, an XHTML author might specify a headline, then a smaller sub-headline, a block of italicized text, a few paragraphs of average-size text, and, finally, a few single-word links. Web browsers will follow these presentation instructions faithfully. However, only the human mind understands that the headline is, in fact, the blog post title, the sub-headline indicates the author, the italicized text is the article's publication date, and the single-word links are categorization labels. The gap between what programs and humans understand is large.
</p><table align="center" class="image"><caption align="bottom">On the left, what browsers see. On the right, what humans see. Can we bridge the gap so browsers see more of what we see?</caption><tr><td><img src="diagrams/presentation-vs-semantics.png" alt="presentation vs. semantics"></td></tr></table><p>
What if the browser received information on the meaning of a web page's visual elements? A dinner party announced on a blog could be easily copied to the user's calendar, an author's complete contact information to the user's address book. Users could automatically recall previously browsed articles according to categorization labels (often called tags). A photo copied and pasted from a web site to a school report would carry with it a link back to the photographer, giving her proper credit. When web data meant for humans is augmented with hints meant for computer programs, these programs become significantly more helpful, because they begin to understand the data's structure.
</p><p>
RDFa allows XHTML authors to do just that. Using a few simple XHTML attributes, authors can mark up human-readable data with machine-readable indicators for browsers and other programs to interpret. A web page can include markup for items as simple as the title of an article, or as complex as a user's complete social network.
</p><p> RDFa benefits from the extensive power of RDF <a href="#RDF">[RDF]</a>, the W3C's standard for interoperable machine-readable data. However, readers of this document are not expected to understand RDF. Readers <em>are</em> expected to understand at least a basic level of XHTML.
</p><div class="div2">
<h3><a name="id84480" id="id84480"></a>1.1 HTML vs. XHTML</h3><p>
To date, because XHTML is extensible while HTML is not, RDFa has only been specified for XHTML 1.1. Web publishers are welcome to use RDFa markup inside HTML4: the design of RDFa anticipates this use case, and most RDFa parsers will recognize RDFa attributes in any version of HTML. The authors know of no deployed Web browser that will fail to present an HTML document as intended after adding RDFa markup to the document. However, publishers should be aware that RDFa will not validate in HTML4 at this time. RDFa attributes validate in XHTML, using the XHTML1.1+RDFa DTD.
</p></div></div><div class="div1">
<h2><a name="id84491" id="id84491"></a>2 Adding Flavor to XHTML</h2><p>
Consider Alice, a blogger who publishes a mix of professional and personal articles at <code>http://example.com/alice</code>. We will construct markup examples to illustrate how Alice can use RDFa. The complete markup of these examples can <a href="alice-example.html">be viewed independently</a>.
</p><div class="div2">
<h3><a name="id84514" id="id84514"></a>2.1 Licensing your Work</h3><p>
In her blog's footer, Alice declares her content to be freely reusable, as long as she receives due credit when her articles are cited. The XHTML includes a link to a Creative Commons <a href="#CC">[CC]</a> license:
</p><div class="exampleInner"><pre>...
All content on this site is licensed under
<a href="http://creativecommons.org/licenses/by/3.0/">
a Creative Commons License
</a>.
</pre></div><p>
A human clearly understands this sentence, in particular the <em>meaning</em> of the link with respect to the current document: it indicates the document's license, the conditions under which the page's contents are distributed. Unfortunately, when Bob visits Alice's blog, his browser sees only a plain link that could just as well point to one of Alice's friends or to her resume. For Bob's browser to understand that this link actually points to the document's licensing terms, Alice needs to add some <em>flavor</em>, some indication of what <em>kind</em> of link this is.
</p><p>
She can add this flavor using the <code>rel</code> attribute (which we'll write as <code>@rel</code> so as not to repeat the word "attribute" too often), which defines the <em>relationship</em> between the current page and the linked page. The value of the attribute is <code>license</code>, an XHTML keyword reserved for just this purpose:
</p><div class="exampleInner"><pre>...
All content on this site is licensed under
<a <span style="color: red;">rel="license"</span> href="http://creativecommons.org/licenses/by/3.0/">
a Creative Commons License
</a>.
</pre></div><p>
With this small update, Bob's browser will now understand that this link has a flavor: it indicates the blog's license.
</p><table align="center" class="image"><caption align="bottom">A link with flavor: the link indicates the web page's license. We can represent web pages as nodes, the link as an arrow connecting those nodes, and the link's flavor as the label on that arrow.</caption><tr><td><img src="diagrams/license.png" alt="two Web pages connected by a link labeled 'license' and two notes with a 'license' relationship"></td></tr></table></div><div class="div2">
<h3><a name="id84624" id="id84624"></a>2.2 Labeling the Title and Author</h3><p>
Alice is happy that adding XHTML flavor lets Bob find the copyright license on her work quite easily. But what about the article title and author name? Here, instead of marking up a link, Alice wants to augment existing text within the page. The title is a headline, and her name a sub-headline:
</p><div class="exampleInner"><pre><div>
<h2>The trouble with Bob</h2>
<h3>Alice</h3>
...
</div></pre></div><p>
To indicate that <code>h2</code> represents the title of the page, and <code>h3</code> the author, Alice uses <code>@property</code>, an attribute introduced by RDFa for the specific purpose of marking up existing text in an XHTML page.
</p><div class="exampleInner"><pre><div <span style="color: red;">xmlns:dc="http://purl.org/dc/elements/1.1/"</span>>
<h2 <span style="color: red;">property="dc:title"</span>>The trouble with Bob</h2>
<h3 <span style="color: red;">property="dc:creator"</span>>Alice</h3>
...
</div></pre></div><p>
Why use <code>dc:creator</code> and <code>dc:title</code>, instead of simply <code>creator</code> and <code>title</code>? As it turns out, XHTML does not have reserved keywords for those two concepts. Alice could boldly choose to write <code>property="title"</code>, but how does a program reading this know whether "title" here refers to the title of a work, a job title, or the deed for some real-estate property? And, if every web publisher laid claim to their own short keywords, the world of available properties would become quite messy, a bit like saving every file on a computer's desktop without any directory structure to organize them.
</p><p>
To enforce a modicum of organization, RDFa does not recognize <code>property="title"</code>. Instead, Alice must indicate a directory somewhere on the web, using simply a URL, from where to import the specific <code>creator</code> and <code>title</code> concepts she means to express. Fortunately, the Dublin Core <a href="#DC">[DC]</a> community has already defined a vocabulary of useful concepts for describing documents, including both <code>creator</code> and <code>title</code>, where <code>title</code> indeed means the title of a work. So, Alice:</p><ol><li> imports the Dublin Core vocabulary using <code>xmlns:dc="http://purl.org/dc/elements/1.1/"</code>, which associates the prefix <code>dc</code> with the URL <code>http://purl.org/dc/elements/1.1/</code>, and</li><li> uses <code>dc:creator</code> and <code>dc:title</code>. These are short-hands for the full URLs <code>http://purl.org/dc/elements/1.1/creator</code>, and <code>http://purl.org/dc/elements/1.1/title</code>.
</li></ol><p>In RDFa, all property names are, in fact, URLs.
</p><table align="center" class="image"><caption align="bottom">Literal Properties: RDFa lets Alice connect not just one URL to another—for example to connect her blog entry URL to the Creative Commons license URL— but also to connect one URL to a string such as "The Trouble with Bob". All arrows are labeled with the corresponding property name, which is also a URL.</caption><tr><td><img src="diagrams/title-and-author.png" alt="relationship value is text"></td></tr></table></div><div class="div2">
<h3><a name="id84801" id="id84801"></a>2.3 Multiple Items per Page</h3><p>
Alice's blog contains, of course, multiple entries. Sometimes, Alice's sister Eve guest blogs, too. The front page of the blog lists the 10 most recent entries, each with its own title, author, and introductory paragraph. How, then, should Alice mark up the title of each of these entries individually even though they all appear within the same web page? RDFa provides <code>@about</code>, an attribute for specifying the exact URL to which the contained RDFa markup applies:
</p><div class="exampleInner"><pre><div xmlns:dc="http://purl.org/dc/elements/1.1/">
<div <span style="color: red;">about="/alice/posts/trouble_with_bob"</span>>
<h2 property="dc:title">The trouble with Bob</h2>
<h3 property="dc:creator">Alice</h3>
...
</div>
<div <span style="color: red;">about="/alice/posts/jos_barbecue"</span>>
<h2 property="dc:title">Jo's Barbecue</h2>
<h3 property="dc:creator">Eve</h3>
...
</div>
...
</div></pre></div><p>
We can represent this, once again, as a diagram connecting URLs to properties:
</p><table align="center" class="image"><caption align="bottom">Multiple Items per Page: each blog entry is represented by its own node, with properties attached to each. Here we've used the short-hands to label the arrows, in order to save space and clarify the diagram. The actual labels are always the full URLs.</caption><tr><td><img src="diagrams/multiple-blog-entries.png" alt="two separate nodes, each with two properties"></td></tr></table><p>
Alice can use the same technique to give her friend Bob proper credit when she posts one of his photos:
</p><div class="exampleInner"><pre> <div about="/alice/posts/trouble_with_bob">
<h2 property="dc:title">The trouble with Bob</h2>
The trouble with Bob is that he takes much better photos than I do:
<div <span style="color: red;">about="http://example.com/bob/photos/sunset.jpg"</span>>
<img src="http://example.com/bob/photos/sunset.jpg" />
<span <span style="color: red;">property="dc:title"</span>>Beautiful Sunset</span>
by <span <span style="color: red;">property="dc:creator"</span>>Bob</span>.
</div>
</div></pre></div><p>
Notice how the innermost <code>@about</code> value, <code>http://example.com/bob/photos/sunset.jpg</code>, "overrides" the outer value <code>/alice/posts/trouble_with_bob</code> for all markup inside the innermost <code>div</code>. And, once again, as a diagram that abstractly represents the underlying data of this new portion of markup:
</p><table align="center" class="image"><caption align="bottom">Describing a Photo</caption><tr><td><img src="diagrams/image-about.png" alt="single node with a creator and title property"></td></tr></table></div></div><div class="div1">
<h2><a name="id84945" id="id84945"></a>3 Going Deeper</h2><p>
In addition, Alice wants to make information about herself (email address, phone number, etc.) easily available to her friends' contact management software. This time, instead of describing the properties of a web page, she's going to describe the properties of a person: herself. To do this, she adds deeper structure, so that she can connect multiple items that themselves have properties.
</p><div class="div2">
<h3><a name="id84953" id="id84953"></a>3.1 Contact Information</h3><p>
Alice already has contact information displayed on her blog.
</p><div class="exampleInner"><pre><div>
<p>
Alice Birpemswick
</p>
<p>
Email: <a href="mailto:alice@example.com">alice@example.com</a>
</p>
<p>
Phone: <a href="tel:+1-617-555-7332">+1 617.555.7332</a>
</p>
</div></pre></div><p>
The Dublin Core vocabulary does not provide property names for describing contact information, but the Friend-of-a-Friend <a href="#FOAF">[FOAF]</a> vocabulary does. In RDFa, it is common and easy to combine different vocabularies in a single page. Alice imports the FOAF vocabulary and declares a <code>foaf:Person</code>. For this purpose, Alice uses <code>@typeof</code>, an RDFa attribute that is specifically meant to declare a new data item with a certain type:
</p><div class="exampleInner"><pre><div <span style="color: red;">typeof="foaf:Person" xmlns:foaf="http://xmlns.com/foaf/0.1/"</span>>
...</pre></div><p>
Then, Alice can indicate which content on the page represents her full name, email address, and phone number:
</p><div class="exampleInner"><pre><div typeof="foaf:Person" xmlns:foaf="http://xmlns.com/foaf/0.1/">
<p <span style="color: red;">property="foaf:name"</span>>
Alice Birpemswick
</p>
<p>
Email: <a <span style="color: red;">rel="foaf:mbox"</span> href="mailto:alice@example.com">alice@example.com</a>
</p>
<p>
Phone: <a <span style="color: red;">rel="foaf:phone"</span> href="tel:+1-617-555-7332">+1 617.555.7332</a>
</p>
</div></pre></div><p>
Note how Alice didn't specify <code>@about</code> like she did when adding blog entry metadata. What is she associating these properties with, then? In fact, the <code>@typeof</code> on the enclosing <code>div</code> implicitly sets the subject of the properties marked up within that <code>div</code>. The name, email address, and phone number are associated with a new node of type <code>foaf:Person</code>. This node has no URL to identify it, so it is called a <em>blank node</em>.
</p><table align="center" class="image"><caption align="bottom">A Blank Node: blank nodes are not identified by URL. Instead, many of them have a @typeof attribute that identifies the type of data they represent. This approach—providing no name but adding a type— is particularly useful when listing a number of items on a page, e.g. calendar events, authors on an article, friends on a social network, etc.</caption><tr><td><img src="diagrams/contact-info.png" alt="single 'blank' node with 4 properties"></td></tr></table></div><div class="div2">
<h3><a name="id85076" id="id85076"></a>3.2 Social Network</h3><p>
Next, Alice wants to add information about her friends, including at least their names and homepages. Her plain XHTML is:
</p><div class="exampleInner"><pre><div>
<ul>
<li>
<a href="http://example.com/bob/">Bob</a>
</li>
<li>
<a href="http://example.com/eve/">Eve</a>
</li>
<li>
<a href="http://example.com/manu/">Manu</a>
</li>
</ul>
</div></pre></div><p>
First, Alice indicates that all of these friends are of type <code>foaf:Person</code>.
</p><div class="exampleInner"><pre><div <span style="color: red;">xmlns:foaf="http://xmlns.com/foaf/0.1/"</span>>
<ul>
<li <span style="color: red;">typeof="foaf:Person"</span>>
<a href="http://example.com/bob/">Bob</a>
</li>
<li <span style="color: red;">typeof="foaf:Person"</span>>
<a href="http://example.com/eve/">Eve</a>
</li>
<li <span style="color: red;">typeof="foaf:Person"</span>>
<a href="http://example.com/manu/">Manu</a>
</li>
</ul>
</div></pre></div><p>
Beyond declaring the type of data we're dealing with, each <code>@typeof</code> creates a new blank node with its own distinct properties, all without having to provide URL identifiers. Thus, Alice can easily indicate each friend's homepage:
</p><div class="exampleInner"><pre><div xmlns:foaf="http://xmlns.com/foaf/0.1/">
<ul>
<li typeof="foaf:Person">
<a <span style="color: red;">rel="foaf:homepage"</span> href="http://example.com/bob/">Bob</a>
</li>
<li typeof="foaf:Person">
<a <span style="color: red;">rel="foaf:homepage"</span> href="http://example.com/eve/">Eve</a>
</li>
<li typeof="foaf:Person">
<a <span style="color: red;">rel="foaf:homepage"</span> href="http://example.com/manu/">Manu</a>
</li>
</ul>
</div></pre></div><p>
And, of course, each friend's name:
</p><div class="exampleInner"><pre><div xmlns:foaf="http://xmlns.com/foaf/0.1/">
<ul>
<li typeof="foaf:Person">
<a <span style="color: red;">property="foaf:name"</span> rel="foaf:homepage" href="http://example.com/bob/">Bob</a>
</li>
<li typeof="foaf:Person">
<a <span style="color: red;">property="foaf:name"</span> rel="foaf:homepage" href="http://example.com/eve/">Eve</a>
</li>
<li typeof="foaf:Person">
<a <span style="color: red;">property="foaf:name"</span> rel="foaf:homepage" href="http://example.com/manu/">Manu</a>
</li>
</ul>
</div></pre></div><p>
Using <code>@property</code>, Alice specifies that the linked text ("Bob", "Eve", and "Manu") are, in fact, her friends' names. With <code>@rel</code>, she indicates that the clickable links are her friends' homepages. Alice is ecstatic that, with so little additional markup, she's able to fully express both a pleasant human-readable page and a machine-readable dataset.
</p><p>
Alice is tired of repeatedly entering information about her friends in each new social networking sites. With RDFa, she can indicate her friendships on her own web page, and let social networking applications read it automatically. So far, Alice has listed three individuals but has not specified her relationship with them; they might be her friends, or they might be her favorite 17th century poets. To indicate that she, in fact, knows them, she uses the FOAF property <code>foaf:knows</code>:
</p><div class="exampleInner"><pre><div xmlns:foaf="http://xmlns.com/foaf/0.1/" <span style="color: red;">about="#me" rel="foaf:knows"</span>>
<ul>
<li typeof="foaf:Person">
<a property="foaf:name" rel="foaf:homepage" href="http://example.com/bob">Bob</a>
</li>
<li typeof="foaf:Person">
<a property="foaf:name" rel="foaf:homepage" href="http://example.com/eve">Eve</a>
</li>
<li typeof="foaf:Person">
<a property="foaf:name" rel="foaf:homepage" href="http://example.com/manu">Manu</a>
</li>
</ul>
</div></pre></div><p>
Using <code>rel="foaf:knows"</code> <em>once</em> is enough to connect Bob, Eve, and Manu to Alice. This is achieved thanks to the RDFa concept of <em>chaining</em>: because the top-level <code>@rel</code> is without a corresponding <code>@href</code>, it connects to any contained node, in this case the three nodes defined by <code>@typeof</code>. (The <code>@about="#me"</code> is a FOAF/RDF convention: the URL that represents the <em>person</em> Alice is <code>http://example.com/alice#me</code>. It should not be confused with Alice's homepage, <code>http://example.com/alice</code>. You are what you eat, but you are far more than just your homepage.)
</p><table align="center" class="image"><caption align="bottom">Alice's Social Network</caption><tr><td><img src="diagrams/social-network.png" alt="8 node network with 12 relationships"></td></tr></table></div></div><div class="div1">
<h2><a name="id85315" id="id85315"></a>4 You Said Something about RDF?</h2><p>
RDF, the Resource Description Framework, is exactly the abstract data representation we've drawn out as graphs in the above examples. Each arrow in the graph is represented as a subject-predicate-object triple: the subject is the node at the start of the arrow, the predicate is the arrow itself, and the object is the node or literal at the end of the arrow. An RDF dataset is often called an "RDF graph", and it is typically stored in what is often called a "Triple Store."
</p><p>
Consider the first example graph:
</p><table align="center" class="image"><tr><td><img src="diagrams/title-and-author.png" alt="single node with two properties"></td></tr></table><p>
The two RDF triples for this graph are written, using the Notation3 syntax <a href="#N3">[N3]</a>, as follows:
</p><div class="exampleInner"><pre><http://www.example.com/alice/posts/trouble_with_bob>
<http://purl.org/dc/elements/1.1/title> "The Trouble with Bob";
<http://purl.org/dc/elements/1.1/creator> "Alice" .
</pre></div><p>
Also, the <code>TYPE</code> arrows we drew are no different from other arrows, only their label is actually a core RDF property, <code>rdf:type</code>, where the <code>rdf</code> namespace is <code><http://www.w3.org/1999/02/22-rdf-syntax-ns#></code>. The contact information example from above should thus be diagrammed as:
</p><table align="center" class="image"><tr><td><img src="diagrams/type.png" alt="blank node with rdf:type foaf:Person"></td></tr></table><p>
The point of RDF is to provide a universal language for expressing data. A unit of data can have any number of fields, and field names are URLs which can be reused by any publisher, much like any web publisher can link to any web page, even ones they did not create themselves. Given data, in the form of RDF triples, collected from various locations, and using the RDF query language SPARQL <a href="#">[SPARQL]</a>, one can search for "friends of Alice's who created items whose title contains the word 'Bob'," whether those items are blog posts, videos, calendar events, or other data types we haven't thought of yet.
</p><p>
RDF is an abstract, machine-readable data representation meant to maximize the reuse of vocabularies. RDFa is a way to express RDF data within XHTML, by reusing the existing human-readable data.
</p><div class="div2">
<h3><a name="id85429" id="id85429"></a>4.1 Custom Vocabularies</h3><p>
As Alice marks up her page with RDFa, she may discover the need to express data, e.g. her favorite photos, that is not covered by existing vocabularies like Dublin Core or FOAF. Since RDFa is simply a representation of RDF, the RDF schema mechanism that enables RDF extensibility is the same that enables RDFa extensibility. Once an RDF vocabulary created, it can be used in RDFa markup just like existing vocabularies.
</p><p> The instructions on how to create an RDF schema are available in Section 5 of the RDF Primer <a href="#RDF-SCHEMA-PRIMER">[RDF-SCHEMA-PRIMER]</a>. At a high level, the creation of an RDF schema for RDFa involves:
</p><ol><li> Selecting a URL where the vocabulary will reside, e.g. <code>http://example.com/photos/vocab#</code>.</li><li> Distributing and RDF document, at that URL, which defines the classes and properties that make up the vocabulary. For example, Alice may want to define classes <code>Photo</code> and <code>Camera</code>, as well as the property <code>takenWith</code> that relates a photo to the camera with which it was taken.</li><li> Using the vocabulary in XHTML+RDFa with the usual prefix declaration mechanism, e.g. <code>xmlns:photo="http://example.com/photos/vocab#"</code>, and <code>typeof="photo:Camera"</code>.</li></ol><p>
It is worth noting that anyone who can publish a document on the Web can publish an RDF vocabulary and thus define new data fields they may wish to express. RDF and RDFa allow fully distributed extensibility of vocabularies.
</p></div></div><div class="div1">
<h2><a name="id85510" id="id85510"></a>5 Find Out More</h2><p>
More examples, links to tools, and information on how to get involved can be found on the <a href="http://rdfa.info/wiki">the RDFa Wiki</a>.
</p></div><div class="div1">
<h2><a name="id85528" id="id85528"></a>6 Acknowledgments</h2><p>
This document is the work of the RDF-in-HTML Task Force, including (in alphabetical order) Ben Adida, Mark Birbeck, Jeremy Carroll, Michael Hausenblas, Shane McCarron, Steven Pemberton, Manu Sporny, Ralph Swick, and Elias Torres. This work would not have been possible without the help of the Semantic Deployment Working Group and its previous incarnation, the Semantic Web Deployment and Best Practices Working Group, in particular chairs Tom Baker and Guus Schreiber (and prior chair David Wood), the XHTML2 Working Group, Eric Miller, previous head of the Semantic Web Activity, and Ivan Herman, current head of the Semantic Web Activity. Earlier versions of this document were officially reviewed by Gary Ng and David Booth, and more recent versions by Diego Berrueta and Ed Summers, all of whom provided insightful comments that significantly improved the work. Bob DuCharme also reviewed the work and provided useful commentary.
</p></div><div class="div1">
<h2><a name="id85538" id="id85538"></a>7 Bibliography</h2><dl><dt class="label"><a name="RDFA-SYNTAX" id="RDFA-SYNTAX"></a>RDFA-SYNTAX</dt><dd>RDFa in XHTML: Syntax and Processing (See <a href="http://www.w3.org/TR/rdfa-syntax">http://www.w3.org/TR/rdfa-syntax</a>.)</dd><dt class="label"><a name="CC" id="CC"></a>CC</dt><dd>Creative Commons (See <a href="http://creativecommons.org">http://creativecommons.org</a>.)</dd><dt class="label"><a name="DC" id="DC"></a>DC</dt><dd>Dublin Core Metadata Initiative (See <a href="http://dublincore.org">http://dublincore.org</a>.)</dd><dt class="label"><a name="FOAF" id="FOAF"></a>FOAF</dt><dd>The Friend of a Friend (FOAF) Project (See <a href="http://www.foaf-project.org/">http://www.foaf-project.org/</a>.)</dd><dt class="label"><a name="N3" id="N3"></a>N3</dt><dd>Notation 3 (See <a href="http://www.w3.org/TeamSubmission/n3/">http://www.w3.org/TeamSubmission/n3/</a>.)</dd><dt class="label"><a name="RDF" id="RDF"></a>RDF</dt><dd>Resource Description Framework (See <a href="http://www.w3.org/RDF/">http://www.w3.org/RDF/</a>.)</dd><dt class="label"><a name="RDFHTML" id="RDFHTML"></a>RDFHTML</dt><dd>RDF-in-HTML Task Force (See <a href="http://www.w3.org/2001/sw/BestPractices/HTML/">http://www.w3.org/2001/sw/BestPractices/HTML/</a>.)</dd><dt class="label"><a name="RDF-SCHEMA-PRIMER" id="RDF-SCHEMA-PRIMER"></a>RDF-SCHEMA-PRIMER</dt><dd>RDF Primer - Section 5 on RDF Schema (See <a href="http://www.w3.org/TR/2004/REC-rdf-primer-20040210/#rdfschema">http://www.w3.org/TR/2004/REC-rdf-primer-20040210/#rdfschema</a>.)</dd><dt class="label"><a name="SWD-WG" id="SWD-WG"></a>SWD-WG</dt><dd>Semantic Web Best Deployment Working Group (See <a href="http://www.w3.org/2006/07/SWD/">http://www.w3.org/2006/07/SWD/</a>.)</dd><dt class="label"><a name="SWBPD-WG" id="SWBPD-WG"></a>SWBPD-WG</dt><dd>Semantic Web Best Practices and Deployment Working Group (See <a href="http://www.w3.org/2001/sw/BestPractices/">http://www.w3.org/2001/sw/BestPractices/</a>.)</dd><dt class="label"><a name="XHTML2-WG" id="XHTML2-WG"></a>XHTML2-WG</dt><dd>XHTML2 Working Group (See <a href="http://www.w3.org/MarkUp/">http://www.w3.org/MarkUp/</a>.)</dd></dl></div><div>
<h2><a name="changes" id="changes"></a>Changes</h2>
<p>
The previous version of this document was a significant rewrite for clarity and simplicity. This version includes only a small handful of updates:
</p>
<ul><li> some typos fixed.</li><li> changed "HTML" to "XHTML" and added Section 1.1 explaining the situation.</li><li> added section 4.1 on custom vocabularies.</li></ul>
</div></div></body></html>