Wednesday, January 31, 2007

Xslt: a simple way to for web template systems

There is a way to do templating with XSLT in the simple form that PHP, Dreamweaver, Strut, Frontpage and in general web developer who relies on templating normally use.

I've worked seven years with Cocoon and one of the weakness I had found in this valid web developing framework is linked to the steep learning curve associated with the xslt language.

What I have discovered is that you can use XSLT in a very simple way:
  • Hiding the complexity of the xsl:template and the xsl:apply-templates concepts
  • Reducing the verbosity of the stylesheet (no more xsl:stylesheet tag required)
  • Giving meaning to the xsl:for-each and xsl:value-of (that using the xsl:template method are mostly useless)
The drawbacks of this kind of use of xslt language is the lost of the power associated with the traditional xsl:template aproach.
So is a question of simple against powerful and I don't want to suggest to anyone what to choose because:
  • Each situation may have different ideal solutions
  • Probably the right approach is incremental
By incremental approach I mean that when someone wants to approach xslt language or has to do some very fast developing can use a quick and dirty approach with the simplyfied form of xslt stylesheet.
When what you have to do is complex and you want to do it in a nice and synthetic form you can approach the traditional way of writing xslt stylesheets.
I write this article because over the years I've seen articles and post on templating with xslt and Cocoon and they were done in a complex way:
What I wonder now is:" Did those guys know that there was a solution to their problem inside xslt???"
I didn't for sure and it surprised me a lot. I wouldn't swear they did... What do you think??

No comments: