Why I don't like XSLT
Monday, November 29, 2010 11:59:00 AM
- The one word that quickly summarizes xslt in my mind is: OVERHEAD!
- Overhead in the form of memory usage. Memory footprints of parsed xslt/xml documents grow proportional to the document size, and are often 3-4 times the size of the document itself. This would go for both the XML data and the stylesheet itself. I mean, c'mon, that's insane!
- Overhead in the form of processing (1). You are required to transform perfectly good data from an _internal_ structure to xml, which will again be transformed (via xslt) to (x)html. Doesn't that already sound like overhead?
- Overhead in the form of processing (2). XML is optimized for readability (although I don't always agree), not speed. As a data format it's way too bloated and flawed for _internal_ representation (as a data exchange format, that's a different story).
- XSL templates are just too verbose. I wanted to shoot myself when I was creating a variable where the declaration spanned 13-14 lines (due to formatting etc) because of some conditionals. var = (other_var) ? "yay" : "nay".. anyone?
- Don't even get me started on the syntax. Who the hell thought it was smart to create a templating language, where the syntax of the templating language itself is the same bloated crap as what is to be generated. It is really hard to distinguish template logic from actual mark-up in comparison to alternative templating languages, which leads on to the next point:
- Generic? I think not. With template toolkit you can easily create templates for all kinds of files and output. XSLT only likes XML. Checking for document validity is great and all, but you can easily achieve that with other means.
Template Toolkit gives so much more flexibility and speed that's this is really a no-brainer. Mainenance is greatly simplified with cleaner templates. Callback-functionality to back-end code is a lot easier to achieve. Generic data-structures generated by back-end modules open for the possibility of converting data to several know formats, rather than only relying on XML (internal perl hashes, json, xml, ...).
These are only the quick points that come to mind right now. I might be able to come up with quite a few other issues, but I'm not going to bother.
















