Sharing a calendar in Sharepoint 2007

One of the most annoying omissions in Sharepoint 2007 is the inability to share calendars between sites and subsites:

  • maintain a master calendar and view it (or part of it) in a subsite, or
  • maintain a calendar in the subsite and “roll it up” with other subsite calendars to a master view in the main site.

Apparently this is rectified in Sharepoint 2010 but if you’re unable to upgrade, and aren’t allowed to build your own webparts, you’ve to look elsewhere for a solution:

  • use a 3rd party webpart (can recommend the Bamboo Solutions offering having used it elsewhere), or
  • hacking together via the page viewer webpart (I never got this to work but your mileage may vary)

However this article describes a 3rd option we implemented which met the requirement by not using calendars at all.  Instead we used XML.

An XML solution in three parts

The XML solution allows a single, master, calendar to be published in multiple subsites, optionally filtering entries to particular subsets.  To implement you need three elements:

  1. source calendar (in XML, not a SharePoint calendar)
  2. presentation/design code (XSL), and
  3. webpart that links the above two together on your site.

Without advanced CSS skills this won’t get you much more than an event list on any site.  But if that’s all you want, and more important is the ability to reproduce that one list on multiple sites, then this approach might work for you.

Source calendar (XML)

In XML a calendar is simply a series of events, with varying parameters that include a date and a name, collected in a parent element.  For our basic implementation we ended up with just that:

  <date>12 August 2011</date>
  <title>Integration testing starts</title>
  <date>23 November 2011</date>
  <title>Integration testing ends</title>

To make it valid just add a definition on the first line:

<?xml version="1.0" standalone="no"?>

From this basis you can obviously add whatever other values you want to note for each event. For example if you want to present or filter by project, or responsibility, just add appropriate values to the XML.

presentation/design code (XSL)

The XSL code is what converts your XML into HTML that can be presented on your Sharepoint page. With the simple calendar schema adopted here this is only a few lines.

First set the scene:

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <xsl:stylesheet version="1.0" xmlns:xsl="">



Then add the XSL proper inside the above framework. The following code will first match our calendar parent element using template-match, before traversing each of our events by using a for-each loop.

 <xsl:template match="CALENDAR">
  <table border="0">
    <xsl:for-each select="EVENT">
      <td><xsl:value-of select="title" /></td>
      <td><xsl:value-of select="date" /></td>

This code puts each event (the “EVENT” elements) into a separate row in a table, with two event values “title” and “date” presented in separate columns.

This code gives you the basic framework for manipulating your XML. However XSL, and HTML/CSS are must more powerful than this example demonstrates. Feel free to research further on how to leverage this approach to really fine-tune the delivery of your calendar data.

For now, however, I will describe one of the most common XSL functions you’ll want in this solution: the ability to present a subset of your calendar entries based on a parameter recorded with each event.

Filtering records

In XSL you filter records by adding a comparison operator to your for-each statement. For example, if we add a “project” attribute to our events, the code to filter to a specific project is a simple change to the for-each command:

 <xsl:for-each select="EVENT[project='Project A']">

This will now only list events that are for “Project A”.  And how do you get entries to be categorised as “Project A” – just add to the XML:

  <project>Project A</date>
  <date>12 August 2011</date>
  <title>Integration testing starts</title>
  <project>Project B</date>
  <date>23 November 2011</date>
  <title>Integration testing ends</title>

Linking webpart

To pull the XML and XSL together on your Sharepoint page, add an XML Webpart.

In this webpart you simply specify the XML and XSL you need to use. You can enter your details directly into the webpart (which negates the whole sharing theme for the XML, and can cause consistency issues with the XSL). Or you can link to external files. With the advantage that those files can exist anywhere in your site architecture.


Using XML to share a single calendar is not for everybody. It’s harder to maintain the entries, and the presentation is never going to be sexy. But as a quick way to stop yourself repeating yourself, it’s worth considering.

One thought on “Sharing a calendar in Sharepoint 2007

  1. Steve


    When generating the XSL to include in the webpart, you don’t need the first line XML definition:

    <?xml version=”1.0″ encoding=”ISO-8859-1″?>

    Just start the definition with the <xsl> tag.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>