Tag Archive for 'groups'

Playing around with XSLT

I recently wanted to have a view of twitter with friends organized into groups the way TweetDeck has it (or at least I suppose it’s the way it has it, as it doesn’t work on linux). So I thought it was a cool project to learn some XSLT. XSLT is basically an XML language for turning an XML document into something else, which can also be XML. As that was exactly what i wanted to do, using the language that was written specifically for that purpose (like a DSL) should make the task very easy and fast. The files to be transformed by the XSL file would be the raw twitter feed and a groups file in which I’d specify the groups that I wanted to display. The XSL would create an XHTML document with the tweets organized into groups depending on the person they came from. It was really fast and the result was mostly what I wanted. I’ve posted the code on github.

If you want to use it you need to create an xml folder and create in there a file named current.xml with the XML from twitter that you want to organize and groups.xml with the following structure:

<groups>
  <group name="Test">
    <user>username</user>
  </group>
</groups>

One group entry per group and one user entry per user in group. That should be it, if you browse to the index.xml file in the main directory you should then get a visualisation of the grouped tweets along with a row in the top of the document with buttons that toggle each group (with some jquery hiding goodness and some quick css):

Also in the repo are merge, count and “id of the first tweet” xsl files that I used to do a simple batch script that updates the feed (using curl and Xalan to fetch 200 updates at a time until there are no more updates to fetch merging it all in the current.xml). It is all very raw and quickly put together at the moment, but in the future I might add more features and make it into a client. However, I hope this might help someone to get into XSLT. I found it to be very interesting and quite powerful and look forward to using it in the future.