Translating XQuery into XSLT

S. Lechner, G. Preuner, M. Schrefl
Lech01a (2001)
Proceedings of the International Workshop on Data Semantics in Web Information Systems (DASWIS 2001) held in conjunction with the 20th International Conference on Conceptual Modeling (ER 2001), November 27-30, 2001, Yokohama, Japan, Springer Verlag, Lecture Notes in Computer Science (LNCS 2465), ISBN 3-540-44122-0, erschienen 2002.
Copy  (In order to obtain the copy please send an email with subject  Lech01a  to


The WWW Consortium (W3C) has recently presented a working draft of XQuery, which is intended to serve as standardized query language for XML. XQuery and other high-level query languages for XML documents are not yet implemented by commercial products. Yet many browsers have already built-in XSLT support for transforming XML documents. XSLT is a standard way of performing structural rearrangement or presentational transformation of XML documents, but formulating complex queries is, compared to XQuery, difficult and error-prone. If XQuery expressions could be translated into XSLT (e.g. by a translator written in Java or XSLT itself), the benefits of Xquery would be immediately available to a wide range of commercial products.

This paper introduces a process for translating queries formulated in XQuery syntax into XSL stylesheets. The process is described independently from a particular implementation by means of an ASM (Abstract State Machine). The ASM traverses the parse tree of a particular query and translates each node into corresponding XSLT commands. The result of this translation process is an XSL stylesheet that can be applied to an XML document in order to perform the given query. The presented ASM can be easily coded in Java or XSLT to implement a prototype XQ2XSL translator.