Linux Journal July 2008

Page 82

INDEPTH

represents the world as a set of triples: subject, predicate and object. Each item in the triple can be a URI, a literal or a blank node (a kind of temporary variable). In practice, the predicate is likely to be a URI in a namespace created for the purpose, like cal:dtstart or cal:summary. Vocabularies and ontologies form the backbone of the Semantic Web. You can define your own, and some tools like Semantic MediaWiki create an ontology for you automatically. When defining the terms in a specialized domain, or when creating a private within-enterprise application, creating your own ontology makes sense. For sharing data with the world, I prefer to reuse existing vocabularies as much as possible. (By vocabulary, I mean an RDF file that defines terms and properties; by ontology, I mean a vocabulary that also contains logical rules.) Some widely used vocabs include the following: I foaf: friend of a friend, for identifying people and other

entities (xmlns.com/foaf/spec/20071002.rdf). I ical: based on the iCalendar W3 standard, for calendar and

event data (www.w3.org/2002/12/cal/ical).

Linux News and Headlines Delivered To You Linux Journal topical RSS feeds NOW AVAILABLE

I vcard: intended as an electronic business card, it has

simple fields for contact information (www.w3.org/ 2001/vcard-rdf/3.0). I dc: Dublin Core, defining core properties like title and

creator (purl.org/dc/elements/1.1). I cc: for Creative Commons licenses (creativecommons.org/ns). I rss: the RSS 1.0 namespace (purl.org/rss/1.0).

Note that in our document, we can choose our own shorthand name for each vocabulary when we list it in the <html> tag. Then, we can use that shorthand to write what is called a CURIE, or Compact URI, like dc:title or foaf:name. In RDFa, those CURIEs are valid URIs and are much easier to read once you get used to them. One of the core ideas of RDF is to be able to use URIs to refer to concepts and things outside cyberspace, and then use them to make logical statements. So, it helps if the URIs are human-readable. Going back to the rodeo schedule example, suppose we want to list the contestants in each event. Now, we get into the power of RDFa—the ability to connect different types of data together in a logical way right in an HTML file. The first step is to pick or create a vocabulary to describe the contestants. FOAF is the standard for referring to people, but I also want to specify that they are contestants in the rodeo. I did a search on Swoogle for the word contestant, and after a few minutes examining the available ontologies, I decided that http://smartweb.semanticweb.org/ ontology/sportevent is the most apt. I also want to add a contact person for the rodeo as a whole, using the vCard vocabulary. So, I added foaf, contact and sportevent vocabularies to the list at the start of the document, which now looks like this: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:cal="http://www.w3.org/2002/12/cal/ical#" xmlns:sportevent="http://smartweb.semanticweb.org/ontology/sportevent#" xmlns:foaf= "http://xmlns.com/foaf/spec/20071002.rdf" xmlns:contact= "http://www.w3.org/2001/vcard-rdf/3.0#" >

Zooming in on just the event itself, we can add some contestants: <div rel="cal:Vevent"> <span property="cal:dtstart" content="20080222T1400-0700">2:00PM</span> : <span property="cal:summary">Bull Riding</span> <ul>List of Contestants:

http://www.linuxjournal.com/rss_feeds

<li rel="sportevent:Contestant" id="Marchi"> <span property="foaf:name" about="#Marchi" >Guilherme Marchi</span><br/>

80 | july 2008 w w w. l i n u x j o u r n a l . c o m


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.