Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XQuery vs XSLT for transforming data

Tags:

xml

xslt

xquery

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

like image 967
metdos Avatar asked Jun 09 '10 07:06

metdos


People also ask

Is XQuery still used?

The designers of XQuery want you to use it as a unified query language for any data store, including XML files, XML databases, and non-XML data stores. Keep in mind that most implementations are experimental and in the technology preview stage. Although XQuery is still a working draft it already has broad support.

Can we use XQuery in XSLT?

For example, you can use XQuery to extract data from an XML database, and XSLT to present the results to users on the web.

Does anyone use XSLT anymore?

XSLT is very widely used. As far as we can judge from metrics like the number of StackOverflow questions, it is in the top 30 programming languages, which probably makes it the top data-model-specific programming language after SQL. But XSLT isn't widely used client-side, that is, in the browser.


2 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.

like image 55
Dimitre Novatchev Avatar answered Nov 16 '22 02:11

Dimitre Novatchev


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.

like image 31
Darknight Avatar answered Nov 16 '22 02:11

Darknight