The joy of Cocoon, XML technologies and beyond

For quite sometime I've been talking and pushing the use of Open RESTful API's. Its so easy now, sign up get a API, Development, Session, etc key and your pretty much away. The only question then is what framework you choose to develop in?
I personally use Apache Cocoon because it allows me to do almost anything I like and its completely dependant on XML technologies like XSL. One of my aims back in 2002 was to use XSL as a tool for almost anything I needed to do again and again. Well it that aim is very real now. For example I was creating quite a few emails with slighly different information in each one. Well I thought about using copy, paste, find and replace. But no need I just wrote up some really simple xml files which contains parts of the infomation then a sitemap in cocoon using a little bit of simple logic to read the URL string and certain parts as a variable for the XSL. Before you know it (timed myself, it took only 45mins with instant message interuptions) I had what I wanted. The only thing which was missing was for the pipeline to send a email at the end. I still had to copy and paste the result into a email. So how would I solve such a problem?

Well from my understanding of Servlets, it shouldnt be too difficult to send messages/streams from Cocoon to a SMTP JAR which sits in the same servlet container? But I'm still a little unsure of how this is exactly done. The other thing I could do is to create a email file which Thunderbird would pick up and send or at least put in the outbox with little user interaction on my part.

Anyhow, one of the issues with cocoon for the longest time was getting content in to it. Yes you have many different neat ways like the Directory reader, Zip reader, standard xml reader, image reader, JSP reader, hey there was even a Database reader which would create a connect to any SQL database. But theres so much more needed in this area, for example a while ago I was looking for a way to analyse lots of CSS and in the end we had depend on a Perl lib which understands CSS and then had to be written to XML before it could be pulled into cocoon. Now theres nothing wrong with this method but you would think a CSS reader would be useful. Along with a EXIF reader which I swear would be so great. All the metadata is sooo useful!! However its all changed now thanks to webservices. I could upload all my pictures to Flickr and use there REST API to pull the metadata out and into Cocoon. And this is the thing, its pretty true of a lot of things now. Want to get the weather in Tokyo? Just grab it from somewhere else, I bet its also more effective than doing it yourself too. And I wonder where things are going with this? Will we get to a point where it will be more effective to get the date or even the time from a webservice?

So the input side is covered, the internal transformation is pretty much there now with XSL 2.0 and Cocoon. But what about the output? Cocoon can output or serialise to almost anything you can think about including SVG, PDF, OpenOffice, Zip, Text, XML, HTML, XLS, etc. But this is the thing which needs the most development at the moment. The user interface for services are still pretty poor. So what options do you have? Well my fav is still SVG but still there very few browsers which support this natively. Which will always be a problem. Then theres the whole Flash thing, which I still really really hate but have accepted a tiny bit in the absence of SVG for some things. There's also tons of Javascript + XHTML solutions being used now, which I'm actually thinking is not so bad now (A lot of these solutions are using standard DOM's which makes them work across all new and coming browsers). has a really good piece about client side processing using Sarissa which I have been messing with recently. XMLHttpRequest has made a huge difference to what can be done on the client side and has issued in things like google maps and google suggest.
Then of course if you want to get really rich theres a whole host of technologies just on the horizon including XUL, XAML, XForms, WebForms2, sXBL, etc. Being a opensource kinda of guy, i'm gunning for XUL with Xforms and sXBL with SVG for my own applications. Can't help be interested in XAML though…

Following on, I've been reading a couple of thoughts from others out there. dispells the meme that REST is not ready? Theres a great little quote from Mark Baker in the same entry.
The same tools that create Java servlets could be used to build REST-based Web services, Baker says. “They follow the HTTP specification, and by following it, they implicitly are following the constraints of the REST style,”
Bang on the money! I was explaining to David the other day over a drink why PHP is great but Servlets are just well different. You cant really compare them, it would be better to compare JSP with PHP but servelts are logically different and simple just like RESTful services. It fits perfectly with the next generation of web 2.0.

Comments [Comments]
Trackbacks [0]

Author: Ianforrester

Senior firestarter at BBC R&D, emergent technology expert and serial social geek event organiser. Can be found at, and