May 02, 2008   Sign In |  About ebizQ |  Contact Us |  Join ebizQ Gold Club

ITGumbo: spicing IT up

IT Copywrite

Technology and application of technology.

ebizQ presents ITGumbo: a spicy blog network where vendors and IT professionals share ideas about creating Business Agility.

Simple steps to add RDFa to web content

In many web content publishing tools it is not possible to modify the contents of <html> and <head> element. Therefore it may not be possible to mention correct Document Type (DOCTYPE) and Content Type (@http-equiv) values. However it is still possible to add RDF normative metadata to your web content. Web content annotated with RDFa is scanned for RDF triples by major Search Engines such as Google and Yahoo!.

"Adding semantics to the web involves two things: allowing documents which have information in machine-readable forms, and allowing links to be created with relationship values" (TimBL, WWW1994).

Vocabulary Namespace -
Add namespace declaration xmlns: to <div>, <p>, <a> etc. elements that contain the annotated content.
Subject -
Add about="" to the <div>, <p>, etc. elements that contain the annotated content. The @about value is the subject in the RDF triple and the value "" of @about suggests that the subject for enclosed annotated content is 'this' document and hence the value of subject IRI shall be IRI of 'this' document as displayed in the browser address bar.
Predicate -
The value of @rel and @property is the predicate in a RDF triple. Add RDF properties i.e. normative metadata from vocabularies such as FOAF, vCard, Dublin Core etc. in the following manner:
  • If <a> element is present then add @rel to <a> element with value as property name from the vocabulary.
  • If <a> element is not present then enclose the data to be annotated in <span> element and include @property to <span> element with value as property name from the vocabulary.
Object -
The value of @href in <a> element and the literal value enclosed within <span> elements are the object values. In brief, @rel must be used if object is a web resource with valid IRI and @property is used when object is a plain literal text. @content is used when the plain literal text value of object rendered by the user agent such as browser is different from the machine processable value.
Example: Semantic Annotation of web content
Plain ContentSemantic Annotation with RDFa
<body>
<h3>Title of this post</h3>
OR
<h3><a href="IRI of this blog post">Title of this post</a></h3>

<p>Content of this post</p>

<a href="home page IRI">Ila Nivas</a>
OR
Ila Nivas

Date: April 15, 2008
</body>
<div xmlns:dc="http://purl.org/dc/elements/1.1" about="">
<h3 property="dc:title">Title of this post</h3>
OR
<h3 property="dc:title"><a href="IRI of this blog post">Title of this post</a></h3>
OR
<h3><a href="IRI of this blog post" property="dc:title">Title of this post</a></h3>

<p>Content of this post</p>

<a rel="dc:creator" href="home page IRI">Ila Nivas</a>
OR
<span property="dc:creator">Ila Nivas</span>

Date: <span property="dc:date" content="20080415T1600-0500" datatype="xsd:datetime">April 15, 2008</span>
</div>
No RDF triples are generated without annotation. RDF triples:

<IRI of this blog post> dc:title "Title of this post" .
<IRI of this blog post> dc:creator "Ila Nivas" .
<IRI of this blog post> dc:date "20080415T1600-0500"^^xsd:datetime .

View RDFa on this web page

  • Drag the 'RDFa Highlight' bookmarklet from here to the bookmarks bar.
  • Open this blog post in the browser.
  • Now click the 'RDFa Highlight' bookmark, the embedded RDFa is highlighted with red border rectangle around the object.
  • The RDF triple can be viewed if you hover mouse over the rectangle.

Validate RDFa

You can test the compliance of your web page RDFa here. If it is valid RDFa you can display the W3C XHTML+RDFa seal Valid XHTML + RDFaon your web page. For compliance with W3C standards the following are correct values:

DocType -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
Content-Type -
application/xhtml+xml is the correct value to allow processing of RDFa attributes by XHTML user applications.

Conclusion: XML contortion is not required to add semantic annotation to web content. RDFa has well-defined syntax, only correct syntax must be used to structure the data with RDFa. In this example it is illustrated how RDFa can be used to annotate credit card data. Similarly RDFa can be used to add semantic annotation to other product descriptions. Many time-saving tools can be built with semantic annotation of web content.

Advertisement

0 TrackBacks

Listed below are links to blogs that reference "Simple steps to add RDFa to web content".

TrackBack URL for this entry: http://itgumbo.com/microsite/MT/mt-tb.cgi/1553

1 Comments

Very nice post. Good to see the uptake. Regarding validation see also [1]. Keep up the great work!

Cheers,
Michael

[1] http://rdfa.info/wiki/How-to-validate

Leave a comment