Plazes Traces + XSLT = RSS

The code described here has been moved into Subversion.

I did some experimenting this afternoon with taking my Plazes XML Traces file and using XSLT to transform it into RSS. I didn’t end up with a complete solution, but I came close:

The problem I ran into is that in the Traces file dates are represented like this:

<location arrival=”2005-06-10”>

Whereas for the RSS file I need something that looks like this:

<pubDate>Sat, 25 Jun 2005 17:36:08 +0100</pubDate>

I need a way of converting dates from one form to another in pure XSLT. I found references here and here that suggested ways around XSLT’s poor date support, but I haven’t implemented them here. As a result, the resulting RSS file is missing a <pubDate>.

I welcome suggestions on how to improve this.

Update: You can use the W3C web-based XSLT processor to do the transformation: the result is RSS that can be fed to an aggregator or newsreader. The pre-packaged URL is here. To reduce load on their XSLT processor, however, please don’t subscribe to this URL.

Comments

Olle Jonsson's picture
Olle Jonsson on June 25, 2005 - 22:54

Darn. Do we need to ask the Plazes guys to export two date fields? Or, of course, we could mung our way through this whole horrible XSLT-ness.

There are currently no XSLT processors that we know of that support date:date-format natively.”

There are currently no third-party implementations of date:date-format.” They said.

Olle Jonsson's picture
Olle Jonsson on June 26, 2005 - 08:58

OK, how about this? First, you grab the XML clump into a PHP string, then you replace all the dates things using this function, and then you output the string as XML with your previous XSLT added.

/**
* Formats date for RSS feeds
*
* @param datetime $date Datetime string
* @return string Formatted date string for RSS feeds
*/
function toRSS ($date) {
return date('D, d M Y H:i:s O', $date);
}
Olle Jonsson's picture
Olle Jonsson on June 26, 2005 - 09:00

I just wanted to add that I got that piece of code from the Time class of the Cake PHP framework.

Edward Vielmetti's picture
Edward Vielmetti on August 10, 2005 - 21:42

I’m thinking about how to get this to generate some javascript that I can include on a page (in Typepad) to show current location based on Plazes.

The equation looks like Traces + XSLT + Feedburner’s RSS to Javascript. The downside is that Feedburner only polls the RSS every so often and you would like this to be real time or more nearly so. I know it would be easier in PHP, but that’s not my environment right now. Feedburner can keep the auth information private and just expose the rewritten RSS.

Any better suggestions for a little hunk of Javascript that prettyprints your current Plaze, with your login and password suitably hidden through a proxy?

Add new comment