I have an XML file with workshops that I would like to submit to the Google calendar. The XML file is maintained by someone else and is updated regularly, so I would like to make it so that Google automatically captures these changes.
I do not have much experience with this, so I hope someone can point me in the right direction.
This is an example of XML that I want to process.
(XML file: "seminar.xml")
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="ical.xsl"?> <seminars> <lastupdate>20150707</lastupdate> <seminar> <speaker>A. Einstein</speaker> <location>Zurich</location> <date>20150607</date> <time>15:45:00</time> <university>Princeton</university> <abstract> <title>On the structure of generalized patent office spaces</title> <content>To be announced.</content> </abstract> </seminar> </seminars>
The most obvious way to achieve this, I would say, is to use the XSLT stylesheet, which processes the XML and creates some kind of file that the Google calendar can read. I have a website / server where I can host this XSL file so that I can hope that I can only make one download of the desired file.
The XSL sheet is as follows.
(XSL file: "ical.xsl")
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" encoding="iso-8859-1" media-type="text/calendar"/> <xsl:variable name="crlf"> </xsl:variable> <xsl:template match="/">BEGIN:VCALENDAR<xsl:value-of select="$crlf"/> CALSCALE:GREGORIAN<xsl:value-of select="$crlf"/> VERSION:2.0<xsl:value-of select="$crlf"/> SEQUENCE:1<xsl:value-of select="$crlf"/> X-WR-TIMEZONE:Europe/Paris<xsl:for-each select="seminars/seminar"><xsl:value-of select="$crlf"/> BEGIN:VEVENT<xsl:value-of select="$crlf"/> LOCATION:<xsl:value-of select="location"/><xsl:value-of select="$crlf"/> DTSTART:<xsl:value-of select="date"/>T154500<xsl:value-of select="$crlf"/> DTEND:<xsl:value-of select="date"/>T164500<xsl:value-of select="$crlf"/> DESCRIPTION:seminar by <xsl:value-of select="speaker"/><xsl:value-of select="$crlf"/> SUMMARY:<xsl:value-of select="abstract/title"/><xsl:value-of select="$crlf"/> END:VEVENT<xsl:value-of select="$crlf"/></xsl:for-each> END:VCALENDAR<xsl:value-of select="$crlf"/> </xsl:template> </xsl:stylesheet>
This works if I process the XML file, attach it to the iCal file ( xsltproc seminars.xml > mycal.ics ) and import it into any calendar in the Google calendar. The result of mycal.ics as follows:
BEGIN:VCALENDAR CALSCALE:GREGORIAN VERSION:2.0 SEQUENCE:1 X-WR-TIMEZONE:Europe/Paris BEGIN:VEVENT LOCATION:Zurich DTSTART:20150607T154500 DTEND:20150607T164500 DESCRIPTION:seminar by A. Einstein SUMMARY:On the structure of generalized patent office spaces END:VEVENT
Now the problem is that (1) Google does not process XML, creating an error while importing, and (2) I'm not sure if this method will automatically βcatch changesβ, as this will require reloading the XML occasionally,
So, is there a way to get Google (or the web server) to process this file so that it is recognized as an iCal file and update it?
Finally, the small problem is that the source XML has a different XSL file inside. Is there an easy way to make something like a symbolic link on my website into this file or include XML without a header so that I can simply replace the original XSL with mine?