Comment by crdoconnor
11 years ago
I would use a language that has a decent XML parser (e.g. python + lxml) for input and a decent templating language (e.g. jinja2) for output.
Assuming it was a simple transformation, the python parsing code could be under 10 lines. Most of what you wrote would be templating. It would be 98% declarative.
If it got complicated though (e.g. you're doing some aggregation or something), the python bit would grow but it probably never end up looking that horrendous, unlike XSLT.
The same pattern could be applied to many other language ecosystems. You just need to make sure you get the best XML parsing library and the best templating language.
You could do the exact same thing using XSLT. eg.
It's a bit of a pointless example because it really depends on the transformations you need. I'm sure in some cases XSLT would be better for the job, and in other cases another language. Most of the time it would generally just depend on your environment, available tools and skillset.
>I'm sure in some cases XSLT would be better for the job
In some (simple transformation) cases XSLT would be no worse, but mostly it would be worse. I can't see it being clearer or easier to maintain under any circumstances.
Once your code evolves toward doing anything mildly complicated you'll wish you never made your transformation in xslt.