In my experience, XSLT is more concise and readable when you're primarily dealing with rearranging and selecting existing xml elements. XPath is short and easy to understand, and the xml syntax avoids littering your code with XElement
and XAttribute
statements. XSLT works fine as a xml-tree transform language.
However, it's string handling is poor, looping is unintuitive, and there's no meaningful concept of subroutines - you can't transform the output of another transform.
So, if you want to actually fiddle with element and attribute content, then it quickly falls short. There's no problem in using both, incidentally - XSLT to normalize the structure (say, to ensure that all table
elements have tbody
elements), and linq-to-xml to interpret it. The prioritized conditional matching possibilities mean XSLT is easier to use when dealing with many similiar but distinct matches. Xslt is good at document simplification, but it's just missing too many basic features to be sufficient on its own.
Having jumped whole-heartedly on the Linq-to-Xml bandwagon, I'd say that it has less overlap with XSLT that might seem at first glance. (And I'd positively love to see an XSLT 2.0/XQuery 1.0 implementation for .NET).
In terms of performance, both techs are speedy. In fact, since it's so hard to express slow operations, you're unlikely to accidentally trigger a slow case in XSLT (unless you start playing with recursion...). By contrast, LINQ to Xml power also can make it slow: just use any heavy-weight .NET object in some inner loop and you've got a budding performance problem.
Whatever you do, don't try to abuse XSLT by using it to perform anything but the simplest of logic: it's way more wordy and far less readable than the equivalent C#. If you need a bunch of logic (even simple things like date > DateTime.Now ? "will be" : "has"
become huge bloated hacks in XSLT) and you don't want to use both XSLT and Linq to Xml, use Linq.