XQuery vs XSLT for transforming data

metdos picture metdos · Jun 9, 2010 · Viewed 10.3k times · Source

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

Answer

Dimitre Novatchev picture Dimitre Novatchev · Jun 9, 2010

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.