XHTML to RDF to iCalendar

This document addresses the interest which has developed in generating iCalendar (RFC 2445) files for consumption in applications like Apple's iCal, Mozilla's Calendar, KOrganizer, and Evolution from other sources, particularly from web pages.

The process is fairly straightforward. An XSLT stylesheet is applied to a valid, well-formed XHTML document (or a Tidy'd HTML document), resulting in an RDF calendar representation. The toIcal Python- and cwm-based utility is used to convert the RDF to iCalendar.


The main issues in parsing from XHTML to RDF are extracting valid dates and extracting or generating valid event IDs. Coordinating date formatting may be the most advantageous way to insure that XSLT can be used. Dates in most W3C calendars take the form DD Month YYYY, with DD - DD Month YYYY and DD Month - DD Month YYYY used to represent date ranges, depending on whether or not the range spans across months or not. The XSLT stylesheet can then use string manipulations to turn reader-friendly dates into iCalendar friendly dates.

Generating event ID's is somewhat more difficult. The RFC calls for a globally unique identifier and suggests techniques for global uniqueness, such as appending a constant, domain-related string to the end of each ID within one calendar, like -somecal@w3.org. Based on XSLT's capabilities, one solution is to use the position() feature. Used correctly, position() can be used to relate an event's location within the document in integer form, which should be unique for the entire document.

Transforming to RDF first allows us to use the data in semantic web applications and to add other useful data from the same page into the RDF data set. The stylesheet used to transform the W3C Member Events calendar [members only] to RDF is publically available for viewing.

The RDF calendar format is under discussion by the www-rdf-calendar mailing list, which meets regularly in IRC and tracks its work online.

XSLT engines to apply stylesheets to documents include Saxon and the W3C's online XSLT service.

RDF to iCalendar

Using Dan Connolly's toIcal Python utility in conjunction with the cwm data processor provides a relatively simple way to generate a valid iCalendar file. See the Makefile [members only] for how the Member Events iCalendar calendar [members only] is generated.

Mozilla's Calendar and KDE's KOrganizer can currently view the calendar correctly.

Ryan Lee, ryanlee@w3.org, last modified on $Date: 2003/03/26 17:42:03 $ by $Author: ryanlee $