Ajax Timelines and the Semantic Web

Explore anything that has a time component with a little Timeline Ajax code.
Timelines Meet the Semantic Web

Generating and updating Timelines becomes simpler when combined with some Semantic Web technologies. The two main ones of use here are an RDF store supporting the SPARQL query language and an XSLT engine to generate JavaScript Object Notation (JSON) files.

Using RDF lets you maintain a single store of information and choose whatever data is of interest using queries. Also, with RDF you can merge information from multiple sources easily into a single Timeline. For example, it might be handy to see the modification times of files along with syslog events on a single Timeline.

Using JSON allows the JavaScript for a page to access time events as normal JavaScript objects. So, you can, for example, center the page by default on the oldest, newest or a named event from the JSON data. This is very handy if the time events change, as the JavaScript will still center the page correctly without modifying the HTML file to point to the desired time explicitly.

RDF is the Resource Description Framework that is the lowest layer of the Semantic Web. Everything is described in terms of triples in RDF—for example, Ben, programs, C++.

Unlike the previous example, triples in RDF are constructed using Uniform Resource Identifiers (URIs) and Objects. A URI is very similar to a URL. The main difference is that URIs are not expected to resolve to something that you can browse on the Net but are intended only to identify something uniquely. Many people use http:// URLs as URIs. The previous example would more likely be expressed in RDF as shown in Listing 7. Normally, people would not be identified uniquely by their first name only.

The additional verbosity of URIs is not really a concern, because most things dealing in RDF will let you define namespaces similar to XML. For example, setting kvo to expand to http://www.kvocentral.org/rdf/ would shorten the first part of the example triple to kvo:person/Ben. The three parts of a triple are referred to as the Subject, Predicate and Object. It is convenient to think of the subject as defining the thing you are describing, the predicate as defining what part of the subject you are describing and the object as the description itself.

SPARQL is a query language for RDF data. SPARQL borrows some notation from SQL. Variables in SPARQL are defined using ?varname. When a variable appears more than once in the where clause it must have the same value for each appearance. For example, the SPARQL query in Listing 8 can return multiple ?x, ?name pairs, but each ?x returned will have a location of Sydney. The optional clause means that if ?x happens to have a digital longitude associated with it, that will be returned as well.

Some of the following code is from or based on the ESW SparqlTimeline page (see the on-line Resources), in particular, the sparql2timeline.xsl file.

I attempted to use the Redland and Rasqal combination for RDF+SPARQL but ran into troubles with SPARQL processing. Redland is still developing its SPARQL query implementation. I then moved to using Jena for RDF processing. The Jena Project is well known for being a feature-rich and robust RDF library. For more information on playing with RSS blog feeds with Jena, see my article “Creating a Planet Me Blog Aggregator”, which appeared in the April 2006 issue of Linux Journal.

Jena is written in Java, and thus, you'll need a JRE. Jena itself is easy to install; simply unzip it somewhere and add its jar files to your CLASSPATH environment variable. For a bash shell, this is shown in Listing 9.

______________________

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState