Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is XSLT an appropriate solution for defining XML transforms instead of using a scripting language like Python?

When is XSLT an appropriate solution for defining XML transforms instead of using a scripting language like Python?

like image 596
Clay3981 Avatar asked Dec 21 '09 22:12

Clay3981


1 Answers

If you don't want to consider things like developer familiarity, I would say pretty much always, assuming you have XSLT 2.0 or at least EXSLT, as XSLT 1.0 is pretty limiting (if you only need structural transformations, 1.0 suffices, but if you need to do anything with the content, you want to stay far away from 1.0). XSLT is specifically designed for transforming XML, and I have found it a lot better for that task than XML libraries in general-purpose programming languages.

Of course, that's all assuming that you only need to transform input XML into some other form. In the real world, requirements change, and suddenly you end up not only having to transform the XML but also perform some operations based on it. And though XSLT is Turing-complete, it's not really a general-purpose programming language, so for future-proofing it might be safer to use another language. Still, I would probably implement the first version in XSLT because I find it faster and easier to understand, and only if XSLT later on proves unsuitable would I consider something else.

like image 120
JaakkoK Avatar answered Oct 01 '22 16:10

JaakkoK