Tuesday, November 22, 2005

I had a comment left on my blog from Bob DuCharme who is the author of the XSLT Quickly from Manning (I am most honoured Bob). Bob has created a master table of contents for all of his XML.com columns about XSLT. These articles include introductions to basic XSLT concepts, hints to approaching typical XSLT problems and tours of XSLT 2.0 features. Many of these articles also feature in his book XSLT Quickly.

You can also obtain Chapter 1 and Chapter 5 sample chapters from XSLT Quickly on the Manning site. Chapter 1 is a brief tutorial introduction to XSLT. Chapter 5 concerns programming using XSLT including coverage of control statements, XSLT extensions, maths, variables and string handling.

At the risk of becoming SPAM! Regular readers (as if I have regular readers!) will have noticed that I have recently succumbed to the commercial dark side by putting Manning banners on my site. I have joined the Manning affiliate programme, this means if you click on one of my banners and actually buy a book I will eventually get some free Manning books. This would be excellent as in the UK we have some kind of 1 pound = 1 dollar exchange thing going on (no wonder we are often called Treasure Island)! Somebody told me that "Borders" is a bargain book shop in the US (not so here), anyhow... Manning books are cool, they are well written by clued up, well respected authors (like Bob) and contain many useful examples (electronic PDF versions are often available). I would have absolutely no hesitation in highly recommending Manning books. Many of these books have become the bibles for their particular technologies e.g. JSTL in Action, Struts in Action, Struts Recipes, Spring in Action. For example I couldn't imagine my developer life without Appendix A: JSTL Reference from Shawn Bayern's JSTL in Action (available for free on the Manning site).

...and the award for most affiliate programme links to Manning in a blog entry goes to...

Friday, November 18, 2005

A colleague of mine said wouldn't it be really great if we could have Google Suggest like functionality in our web applications. Applications like our contacts directory would really benefit. He said this in such a wistful way that I sensed he thought it was highly unlikely that this would ever happen.

I had a couple of hours to kill so I thought I'd take a look at the problem. Having perused the obfuscated Google Maps JavaScript code previously I knew that reverse engineering Google Suggest was probably a non-starter. I immediately stumbled upon ObjectGraph's Dictionary which exhibit's something like the desired behaviour. There was even a helpful explanation and sample source code written in JavaScript and ASP. This was now far too tempting a challenge to resist so I set about writing a similar application using JSTL.

Firstly the backend database, my initial contact directory example used a dataset of 30000 tuples of data. I wanted to use an embedded database since I was sure that our DBA's would not be happy if I ran a potentially labour intensive application against their important data. I initially tried to import the data into HQLDB but it was flaky and kept running out of memory, not a good start. I had a quick scout about and settled on giving Apache Derby a go. Apache Derby recently graduated from the Apache Incubator but in this case this did not mean it was Alpha code. Derby was only in the incubator for the transition period from the commercial database CloudSpace into the open source Derby project.

Derby contains a very useful interactive shell that I could use from the command line to quickly install my data. For illustrative purposes I have created a tiny version of the application using the chemical element data from the periodic table.

Granted this is not yet perfect but I think you'll agree it is nethertheless very impressive and it was not a very complicated thing to do either. Allowing the world at large to access this application will also give me a pretty good idea of how robust this mechanism is although if my blog goes offline you'll know why!

Sunday, November 06, 2005

O'Reilly's Distributing the Future podcasts

For those of you in the dark about what a podcast is, a podcast is essentially a RSS feed which links to audio files rather than web pages. The podcast I have been listening to is O'Reilly's Distributing the Future, which as you might expect from O'Reilly contains some very high quality content.

I'm still in the middle of listening to the recent batch concerning Web 2.0 and the O'Reilly sponsored Web 2.0 conference. I may transfer the MP3's to my pre-iPod Creative MuVo 128Mb MP3 player but in contrast to the usual assortment of background music I keep on it, I really do intend to listen to these broadcasts carefully. Some very interesting points were made by Marc Hedlund in the Data for Web 2.0 entry. He was speaking about the merging of online and offline content. He mentioned Google Desktop which I have coincidently been looking at this week.

Google Desktop

Google Desktop's (GD) new sidebar provides some Apple Dashboard / Konfabulator like functionality. The real core functionality of GD is that it provides a search engine facility for the files on the local harddisk, the clever bit is that when I access Google from my browser I now have an additional options to search my local hard disk in the same way as I would search the web. This is partially achieved by the GD client software installing a "web server" on my machine for the local search. Marc Hedlund makes the point that many people do not understand that although they can search their local files via Google that data is not accessible to anyone else using Google!

Oracle Collaboration Suite

I attended a technical presentation given at my workplace by Oracle this week about Oracle Collaboration Suite. [engage rant mode] Now as the old saying goes 'when you all you have is a hammer, everything looks like a nail'. Oracle's Hammer is called the Oracle 10g Database and the nails in question include e-mail, calendar, voicemail, mobile communication, content management, search and file management. Apologies as I might be guilty of paraphrasing this in a quite cynical way! Oracle are completely open standards based and as long as you only every intend to use Oracle's email server, calendar server, LDAP server, application server, database, search technology, single sign-on mechanism, web service APIs, development software, and development tools (and a few other Oracle bits and bobs) you should be just fine!

Undeniably impressive was the concept of "workspaces" which looked like a quick way to get Yahoo/Google Groups style of web presence established quickly.

For quite a bit of the presentation I was told how I could upload my files using WebDAV to a backend database and this could then be accessed by others over the web. I got the impression that all we would need to do this was a hefty 10 processor server with a couple of terabyte hard disk (or 5 suitably configured 2 processor Linux machines), some extensive capacity planning, a cultural overhaul and complete organisational restructure and then the Oracle Collaboration Suite would be a very good fit for our organisation. [disengage rant mode]

To be fair I can see the some clear benefits of this approach but I couldn't help thinking that I could virtually already do some of this "on the cheap" by simply installing a web server on my workstation. It would seem that centralizing all our services on one server in the midst of the general trend to farming our processing to the client side is a bit like urinating into the wind.

The future?

There is currently a finite number of internet ports on my workstation, there is therefore a limit to the number of web servers I can reasonably install on my machine. This becomes especially critical if each client requires multiple ports for secure and insecure connections, etc.

There is a lot of potential for a "mashup" of the technologies using AJAX and Greasemonkey married to the Google Desktop style of local / remote web interaction. The fact that I heard Mitchell Baker talking about Greasemonkey in a "Distributing the Future" podcast and Mark Pilgrim seems to be writing a book about it fills me with expectation that it will soon become an important development tool that I can't ignore. There may well come a time when a local web server installation will become integral part of the web browser itself. If this web server contained a JavaScript scripting engine like Mozilla's Rhino, all the better. If the web is going to make a transformation from Web 1.0 where it is essentially a "Pull" (read only) to Web 2.0 where it will be more "Push and Pull" (read and write) medium then, to me at least, it makes total sense that we will have all have webservers on our workstations (even if this is less obvious than say a local install of Apache HTTPD is now). I hope that the need for this kind of technology is identified more widely soon so that a standards body can emerge and establish a multi-vendor reference implementation and common programming interface. Is this what Web 2.0 will become? I may have more insight when I've finished listening to the "Distributing the Future" podcast!

With the help of Satish Sekharan of the Memorial University of Newfoundland, I have been experimenting with Struts Bridge (part of the Apache Portals Bridges project) which can be used port a Struts application to JSR168 portlet.

Tuesday, November 01, 2005

Luca Zappa's Brilliant Button Maker is a most impressive and useful application. It primarily uses PHP and the GD library to do its heavy lifting. I've used the GD library in a past life when I was a Perl programmer. I thought I'd see just how easy it was to use Ditchnet's 2D taglib to produce 80x15 buttons like Luca's application does. The answer is that 2D taglib is surprisingly easy to use and the resulting JSP page does not leave me feeling dirty like many "hacky" methods I've used previously do. The 2D taglib supports implicit objects in much the same way that JSTL does (I suspect that this is why it appears to require a 2.4 servlet container). Any object I can set on a page using JSP/JSTL I can access inside the 2D taglib scriptlet. I installed the wonderful Silkscreen font which is widely used in antipixel style buttons. I located a Hex2Color method in Traverse Technologies Open Source Fulcrum product and copied it into my page and after a little fiddling I've created a fairly simple JSP page that can create 80x15 buttons like this:

The simple script is shown below (I haven't yet tried the Java 2D API image support). Luca's HTML form and JavaScript cleverness could easily be converted to sit in front of this JSP powered Button Maker.

At sometime in the future browser vendors will agree upon a common standard for web graphics using SVG or WHATWG's Canvas tag or some other new standard. Until that time this tag library can enable cross platform dynamic graphics. A slight drawback of the 2D taglib is that it appears to require a 2.4 servlet container (e.g. Tomcat 5+).

I wouldn't describe myself as a AWT programmer but using this tag library was quite easy. I located an example of using the Java 2D API in Sun's Java Tutorial in the section on Constructing Complex Shapes from Geometry Primitives. Adapting the tutorial's example I developed my script thus:

and lo' and behold it created a Pear (and a mighty fine pear it is too! Sorry I couldn't resist the Benny Hill style innuendo).

I was most impressed and am already thinking about how I might use this to produce a Brilliant Button Maker style application. Another impressive thing is that, this method is virtually a scriptlet and yet I loved it! I started thinking that there must be other ways to create innovative and more generic non-JSP scriptlets inside JSP pages and there is, BSF.

Scripting in JSP, XSLT and BSF

BSF is one of those products that I have seen mentioned before but I have never previously taken the time to find out what exactly it does. It turns out it enables the incorporation of script languages in a JSP (amongst other things). Using BSF I can execute Python, TCL or Javascript (and other scripting languages) directly in my JSP.

Immediately I thought how cool it would be to make use of Rhino's support for E4X in my JSP pages but unfortunately it seems that BSF does not yet work with the latest version of Rhino. Nevertheless it looks like it could be a useful resource. Then I noticed that Xalan supports BSF for scripting. This means I can write an XSLT which, for example, makes use of external JavaScript function. Although this is interesting this seems a little too much like what Microsoft are doing with HTML Applications. Something about the concept of writing a complex Xalan specific application just seems a little standards ignorant and wrong to me.