Posts Tagged ‘atom’

Link Elements in GCalendar Event Feeds

Posted on timeApril 27th, 2008 by userRay Baxter    flagNo Comments

A question from the for the Google Calendar Data API Developer Forum.

Hi all,

for (CalendarEventEntry event : calEventList) { 
    for (Link link : event.getLinks()) { 

above code fragment prints three types of links, what these are meant for?
What these links signify in the feed.


This is a question that I had been meaning to address, but I was planning to get to it after I addressed all the different urls that are used in the GCalendar API. Actually this question is easier and more straight-forward to answer, so it makes sense to answer this first. I’ll defer the larger questions of GCalendar event feeds and generic Atom feeds for a later post.

Here’s a complete entry feed (as formated with tidy -xml -indent):

<?xml version='1.0' encoding='utf-8'?>
<entry xmlns=''
  <category scheme=''
  term='' />
  <title type='text'>Tennis with Beth</title>
  <content type='text'>Meet for a quick lesson.</content>
  <link rel='alternate' type='text/html'
  title='alternate' />
  <link rel='self' type='application/atom+xml'
 href='' />
  <link rel='edit' type='application/atom+xml'  href='' />
    <name>Ray Baxter</name>
    <gd:feedLink href='' />
  <gd:eventStatus value='' />
  <gd:visibility value='' />
  <gd:transparency value='' />
  <gCal:uid value='' />
  <gCal:sequence value='0' />
  <gd:when startTime='2008-04-17T08:00:00.000-07:00'
  endTime='2008-04-17T10:00:00.000-07:00' />
  <gd:who rel=''
  email='' />
  <gd:where valueString='Rolling Lawn Courts' />

Coming to Vijay’s question, there are three elements in this feed. They are:

<link rel='alternate' type='text/html' href='' title='alternate' />
<link rel='self' type='application/atom+xml' href='' />
<link rel='edit' type='application/atom+xml' href='' />

The links are named for their relations, i.e. the values of their rel attributes.

The first link is the alternate link, so called because it is an alternative version of the content of this event. In this case the alternate version in html format as you can see by the type='text/html' attribute. Because this calendar is public, you can click on that link and see the event in your browser. Try it.

The second link is a self link. That is the the xml feed for this event, and can repull the event from this feed (in the event that Google’s servers are working, which they don’t appear to be currently.) Notice that the http attribute of the self link is exactly the same URL as the .

<link rel='self' type='application/atom+xml'
 href='' />

The self link may not have been the location from you pulled the event. You might have pulled an entire calendar of events (which would have it’s own, distinct, self link) or you might have made a query for events matching some pattern and retrieved a number of events for that feed (which would ought have it’s own self link, but I haven’t verified).

Finally there is the edit link. This is the URL that you use to make changes to the event. Sending a DELETE request to this URL will delete the event. Sending a PUT request will replace event’s data with the data that you send.

For reference, the self and alternate link relations are specified as part of the Atom Syndication Format (RFC4287) and the edit relation is specified as part of the Atom Publication Protocol (RFC5023). A convenient table of all the Atom link relations is here. That table will come in handy as we examine the other link relations in GCalendar feeds.

Any other questions? Leave them in the comments and I’ll get to them as I can.

tagTags: , , , ,


Recent Posts


Relevant Links


Date and Time



iCalendar Tools

Online Calendars




Zend GData