Xquery and XSLT: an easy way to manage XML

Wednesday, July 21, 2010

The XSLT and XQuery standards were created by different working groups within W3C. The both share the same data model, type system and function library, and both include Xpath 2.0 as a sub language. XQuery was initially created as a query language that would work with large collections of XML documents; it can also work with individual documents. So, its capabilities overlap with XSLT, which was designed to allow input XML documents to be transformed into XML or other formats.

Anyway, there are great differences between these languages. XSLT was thought of like of a style sheet language, whose primary purpose was to render on screen the XML code, for the commodity of the human eye. XQuery was conceived more like a database query language, similar to SQL. Therefore, XSLT is better handling the documents with more flexible structure, while XQuery better manipulates the relational joints in database.

As usability studies have shown, the XQuery language is easier to learn, especially for people that have previous experience of SQL and other database languages. XQuery is a smaller language, able to create more concise programs. In contrast to XQuery, an orthogonal language, XSLT is more flexible, being a two-language system in which XPath expressions can be nested in XSLT expressions, but not vice-versa. Another strong point of XSLT is that it allows making small changes to a document, by using a coding pattern that involves an identity template, which copies and modifies the selected nodes on the fly. XQuery has no equivalent pattern, but it can appear in the following versions. Another facility that cannot be found in XQuery is any mechanism of polymorphism. The absence of this capability starts to be felt when writing larger programs, or when writing code meant to be reusable in different environments. In this area, XSLT offers the possibility to dynamically match template rules and to override rules using xml:import, that make it possible to write applications with multiple customization layers. The absence of such features in XQuery make it very amenable to static analysis, and also it becomes easier to detect errors in the XQuery code at compile-time.

XSLT 2.0 uses XML syntax, which makes it rather verbose in comparison to XQuery 1.0. Many applications take advantage of this, by using XSLT to read, write and modify style sheets dynamically as a part of a processing pipeline. By contrast, the XQuery code is more suitable for embedding with traditional programming languages, like Java or C#. If necessary, XQuery can be expressed in XML code, which is called XQqueryX. It is very verbose and hard to understand but can be easily processed for example with XSLT style sheets.


 
We prefer Bluehost Hosting
 
Text Space Available
Your Text
www.Domain.com
Posicionamiento Web Mexico
Servicios: SEO, Marketing en Internet, Google Adwords y Optimizacion Web
www.SEOwebMexico.com

WooThemes - WordPress themes for everyone

Quick Links
Our Friends
Cool Places
Visit also
About Us