http://qs321.pair.com?node_id=344355

Twice in the last week, and many times before, I have seen a question about XML answered by a short post saying in essence just use an XSLT stylesheet.

This irks me to no end, and, after thinking a bit about it, I thought it deserved a meditation.

My first comment would be: show me the code! Here on Perlmonks we tend to answer questions with Perl code, showing ways to solve the poster's problem. For some reason, invoking XSLT seems to absolve people from doing so. Please, if it is so easy to use XSLT, then show us how. After all most questions here ould be answered with a short "just use Perl" comment. Or "just use assembly language" for what matters. Posting some code would indeed show how easy it would be to use XSLT to solve the problem... or not. XSLT is not an appropriate tools for all XML transformations. It would also educate us about XSLT, and generally be a lot more useful than just waving the magical XSLT wand.

I also have a problem with the word stylesheet. It might be the usual designation for a piece of XSLT, but I think it hides the fact that XSLT is code. XSLT is a programing language and you code in it. Stylesheet is a great word for PHBs to use: it implies that the task is simple, should take very little time, and that the skill level involved is minimal. As programers I think we should consider it a very dangerous word. A long time before XML even existed, there was a language called FOSI, used to format SGML documents. My company used it to format aircraft manual. It was a real tough battle to get the powers that be to admit that writing a proper FOSI stylesheet for a complex manual took about a month. After all it was only a stylesheet. Don't let this happen to you.

Finally, my, admittedly limited, experience with XSLT is that it doesn't offer much that Perl + a good module would: on the plus side it leads to safe, side-effect free code, that is easy to reuse. On the minus it is very verbose, the language gets in the way a lot more than Perl, both syntactically (processing XML with an XML syntax is a sure way to lead to delimiter collision) and semantically (as a drawback of the no-side-effect philosophy) and it lacks the wealth of modules that CPAN offers. Overall the select-with-XPath => transform pattern is very similar in XSLT and in XML::LibXML, XML::XPath or XML::Twig code.

In short, yes coding in XSLT can be an option for XML transformation, but if you want to recommend it, then just prove it!