What do you use in your applications for transforming XML data to other data types? WHY?
3 Answers
While XQuery can be used for simple transformations, it lacks the power and sofistication of XSLT (especially templates and the <xsl:apply-templates>
instruction).
XSLT is a language that was especially designed to process tree structures. It is still best at doing this.
In cases when accessing an XML database it would be a good decision to use (the efficiency of) XQuery to extract the necessary XML nodes and then do the transformation with XSLT from here on. Some XSLT 2.x / XQuery processors do allow this (via extensions) even now. The next wave of XSLT 2.x/XQuery 1.x specifications will most probably make such interoperability an official feature of these languages.

- 240,661
- 26
- 293
- 431
If you look at the Wikipedia Entry they have a section that compares the two.
In my view I see XSLT as a Programmable presentation layer for data.

- 2,460
- 2
- 22
- 26
It depends what type of "transformation" you need, XQuery allows you to perform queries on your XML data, a bit like SQL.
XSLT allows you to apply a style on XML, like CSS does with HTML.

- 824
- 5
- 11
-
8I totally disagree with the statement "XSLT allows you to apply a style on XML, like CSS does with HTML.". XSLT is not to XML what CSS is to HTML. CSS tells a processor how to display the HTML. XSLT is used to transform the data into something else. You can use XSLT to transform XML to HTML so that a processor knows how the data should be displayed, but how the processor displays the resulting HTML has nothing to do with XSLT. – Daniel Haley Jun 11 '10 at 01:42
-
XSLT is far more sophisticated than CSS. With XSLT you can add/remove elements and attributes to or from the output file. You can also rearrange and sort elements, perform tests and make decisions about which elements to hide and display, and a lot more. – Premraj May 20 '15 at 12:10