
XQuery in the Browser Ghislain Fourny Markus Pilman Daniela Florescu Systems Group Systems Group Oracle ETH Zürich, Switzerland ETH Zürich, Switzerland Redwood City, CA, USA [email protected] [email protected] dana.fl[email protected] Donald Kossmann Tim Kraska Darin McBeath Systems Group Systems Group Elsevier ETH Zürich, Switzerland ETH Zürich, Switzerland West Chester, OH, USA [email protected] [email protected] [email protected] ABSTRACT 1. INTRODUCTION Since the invention of the Web, the browser has become Over the years, the code producing Web pages has kept more and more powerful. By now, it is a programming and moving back and forth between the client and the server. execution environment in itself. The predominant language Many applications are server-side, many others are client- to program applications in the browser today is JavaScript. side, and the borders are blurred. After a period in which With browsers becoming more powerful, JavaScript has been almost all the code was on the server (thin-clients), we are extended and new layers have been added (e.g., DOM-Sup- now experiencing the AJAX and Web 2.0 trend, in which a port and XPath). Today, JavaScript is very successful and great deal of code is executed on the client again. Client- applications and GUI features implemented in the browser side software today means browser-embedded software, so have become increasingly complex. The purpose of this pa- that there is no installation. The browser is no longer just per is to improve the programmability of Web browsers by a rendering engine, it has become a programming platform, enabling the execution of XQuery programs in the browser. more powerful than ever. Although it has the potential to ideally replace JavaScript, The most popular programming language for the browser it is possible to run it in addition to JavaScript for more flex- today is JavaScript. JavaScript was specifically designed to ibility. Furthermore, it allows instant code migration from run in a Web browser and, thus, JavaScript is a good match the server to the client and vice-versa. This enables a signif- for the development of client-side programs. In particu- icant simplification of the technology stack. The intuition lar, JavaScript is well-suited for programming event-based is that programming the browser involves mostly XML (i.e., user interfaces in the Web browser. All main-stream Web DOM) navigation and manipulation, and the XQuery family browsers today support the execution of JavaScript natively. of W3C standards were designed exactly for that purpose. In addition to JavaScript, there are several alternatives to The paper proposes extensions to XQuery for Web browsers effect browser-embedded application programming. First, and gives a number of examples that demonstrate the use- JavaScript has been extended in order to embed XPath fulness of XQuery for the development of AJAX-style appli- code into a JavaScript program. XPath is useful in order cations. Furthermore, the paper presents the design of an to declaratively navigate the DOM that represents the Web XQuery plug-in for Microsoft's Internet Explorer. The pa- page. Second, the Google Web Toolkit (GWT) is a popular per also gives examples of applications which were developed tool that allows cross-compilation from Java to JavaScript. with the help of this plug-in. GWT helps Java programmers to get started with program- ming the Web browser without the need to learn a new pro- gramming language. Furthermore, GWT enables the devel- Categories and Subject Descriptors opment of both server-side and client-side application code D.3.2 [Software Engineering]: Language Classifications| in a uniform way. Another extension provided by Google is XQuery; H.4.0 [Information Systems Applications]: Ge- the Gears framework which, among others, supports persis- neral tent data (i.e., database access with SQL) and threading as part of JavaScript programs. Finally, Adobe Flash and Flex are popular ways to program powerful user interfaces in the General Terms Web browser. Design, Languages, Performance, Standardization The purpose of this paper is to provide another alternative to program applications inside the Web browser: XQuery. Keywords The goal is to combine the advantages of the existing alter- natives (e.g., JavaScript, XPath, GWT, and Gears) into a XML, XQuery, browser, script, scripting, JavaScript, DOM, single, uniform, and powerful offering. Because it is Turing- HTML, XHTML, events, stylesheets, CSS, client-side pro- complete, XQuery is powerful enough to implement any- gramming, mash-up thing that can be implemented by JavaScript or GWT. How- Copyright is held by the International World Wide Web Conference Com- ever, XQuery can also co-exist with existing technologies in mittee (IW3C2). Distribution of these papers is limited to classroom use, the Web browser, thereby re-using existing JavaScript and and personal use by others. Flex application code and using XQuery to implement func- WWW 2009, April 20–24, 2009, Madrid, Spain. ACM 978-1-60558-487-4/09/04. tionality that is not well supported by the existing tech- power of XQuery and the plug-in are available at http: nologies. This also provides a graceful evolution of existing //www.xqib.org. systems and to compensate for features that are not well • Show that building an XQuery-on-all-tiers application supported by XQuery today. from scratch significantly simplifies the technology stack. XQuery has several compelling reasons why it should be The remainder of this paper is organised as follows: Sec- used in the browser. First, XQuery is a super-set of XPath tion 2 describes the state of the art and gives the main fea- which is already heavily used inside Web browsers in order tures of JavaScript, XPath embedded in JavaScript, GWT, to navigate the DOM. XQuery is not only useful to navigate Gears, and Flex. The goal of our work is to combine these the DOM; it can also manipulate the DOM in a declarative features into a more powerful programming framework based way, it supports declarative access to persistent data (like on XQuery. Section 3 gives a brief overview of the XQuery SQL in Gears), it has a powerful function and operator li- family. Section 4 shows the proposed extensions for XQuery brary (e.g., for dates and times), and it supports scripting so that it becomes a candidate for Web browser-embedded (like JavaScript). In a nutshell, XQuery was designed to programming. Section 5 gives the design of an XQuery plug- process and correlate data on the Web and that is exactly in for the Internet Explorer. Section 6 describes our expe- what AJAX-style programs and Web mash-ups need to do. rience in using this plug-in for two example applications as Section 6 gives an example application that show-cases this well as notes on XQuery-only web applications. Section 7 property. Furthermore, XQuery is carefully designed to be contains conclusions and shows avenues for future research. highly optimisable. Second, XQuery runs on all application tiers (database, 2. STATE OF THE ART middleware, and Web browser) and is thus highly portable. Given the growing importance of the Web browser, a num- For instance, all major database vendors (e.g., IBM, Mi- ber of alternative techniques to develop Web browser-based crosoft, and Oracle) have implemented XQuery as part of applications have been developed. This section gives an their database product and many middleware products (e.g., overview of the most prominent languages and tools: Java- BEA's workflow engine, information integration product, Script, XPath embedded into JavaScript, GWT, Gears, and and enterprise service bus) support XQuery. Hence, XQuery Flex. The goal of this work is to combine the advantages of code can be shipped between different tiers which can be these languages and tools into an XQuery application devel- exploited in order to reduce cost. Section 6 presents an ex- opment framework. ample application that show-cases this advantage. Third, XQuery is a family of standards endorsed by the 2.1 JavaScript W3C so that it is standardised and the whole XQuery familiy JavaScript was developed in 1995. The initial motivation interoperates well with other W3C recommendations; e.g., was to validate forms at the client-side without the need to XML, XML Schema, REST/Web Services. The XQuery exchange data with the server (which was much slower than family is a complete and powerful programming model. today). Today, JavaScript has become a popular language Finally, there is a significant industry push for XQuery. A and several extensions have been added by vendors to make great deal of tools are developed and products are maturing. it a powerful programming tool for the Web browser. AJAX XQuery is taught in the curricula of the Computer Science (Asynchronous JavaScript And XML) is probably the best programs of many universities. As a consequence, it can example of how JavaScript can help build powerful client- be expected that more and more XQuery programmers will side applications. JavaScript is a great programming lan- soon appear on the job market. guage for the browser because JavaScript was specifically Again, the goal of this work is to study XQuery as an al- designed for this purpose. ternative and complementary technology in order to imple- An important feature of JavaScript is that it supports ment client-side applications inside the Web browser. That event-based programming which is needed for modern user is, the purpose is to study the potential of this technology interfaces. A second feature of JavaScript is that it supports and see, with the help of examples, how it co-exists with ex- DOM, which is the API used in order to navigate and ma- isting technology such as JavaScript.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages10 Page
-
File Size-