19

What do you use in your applications for transforming XML data to other data types? WHY?

redcalx
  • 8,177
  • 4
  • 56
  • 105
metdos
  • 13,411
  • 17
  • 77
  • 120

3 Answers3

14

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.

Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
1

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.

Darknight
  • 2,460
  • 2
  • 22
  • 26
-2

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.

Romain Deveaud
  • 824
  • 5
  • 11
  • 8
    I 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