<<

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., 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. To this end, this paper nipulate Web pages in a Web browser. A third feature of reports on the following contributions: JavaScript is its availability in all browsers. • Show that XQuery is a viable option for client-side, XQuery naturally supports the navigation and manipula- browser-embedded applications. We present examples which tion of Web pages because XQuery supports the navigation show the advantages and expressive power of XQuery for this and manipulation of XML and, thus, any kind of data stored purpose. behind a DOM API. The support for event-based program- • Extend XQuery for the browser, thereby providing a ming in XQuery will be detailed in Section 4. As a result, syntax for event-based programming, CSS, and access to XQuery is a viable candidate to replace JavaScript. As will the Browser Object Model. become clear in the remainder of this paper, however, both • Design a plug-in for running XQuery in the Web browser. XQuery and JavaScript can also co-exist in a single applica- A first release of this plug-in for Microsoft’s Internet Ex- tion. plorer is available for free download and open sourced at http://www.xqib.org. An implementation of the plug-in 2.2 Embedded XPath in JavaScript for Firefox is currently on the way and should be ready in Since it is quite cumbersome to navigate Web pages using 2009. DOM, Web browsers have supported XPath for a long time. • Give two application examples, a Web mashup and a In particular, it is possible to embed XPath expressions into publishing application, which demonstrate the flexibility of JavaScript programs. Many browsers support this feature. XQuery to integrate horizontally and vertically into an ap- The following example demonstrates this feature for Firefox: plication stack. Additional examples that demonstrate the var allDivs, newElement; allDivs = document.evaluate( In order to run ActiveScript, a Web browser must install "//div[contains(., ’love’)]", a Flex plug-in, in the same way as proposed in this work document, null, XPathResult. for running XQuery in a Web browser. Like JavaScript, UNORDERED_NODE_SNAPSHOT_TYPE, null); ActiveScript and XQuery can co-exist in the Web browser - if (allDivs.snapshotLength > 0) { in fact, all three programming languages can be embedded newElement = document.createElement(’img’); into a Web page. This way, it is possible to design fancy user newElement.src = ’http://.../heart.gif’; interfaces with Flex and program more advanced application document.body.insertBefore(newElement, logic and Web page manipulation with, say, XQuery. Such document.body.firstChild); an approach has been taken already in several projects at } ETH Zurich. This JavaScript code uses XPath as part of the document. evaluate function. This JavaScript function is called with 3. XQUERY OVERVIEW an XPath expression which looks for all divs containing the This section gives an overview of XQuery, the XQuery word ”love”. If such an occurence is found, an image with a Update Facility, the XQuery Scripting Facility as well as heart (i.e., “heart.gif”) is inserted into the Web page. Web services and REST support in XQuery. At the end of Obviously, XQuery naturally supports navigation of Web this section, we explain why XQuery is suitable for browser- pages with XPath because XPath is a sub-set of the XQuery embedded programming and enables the implementation of programming language. That is, all XPath expressions can whole applications in a single programming language, there- be executed by an XQuery processor. by simplifying the technology stack of modern Web-based 2.3 Google Web Tools (GWT) applications. As mentioned in the introduction, GWT enables Java pro- 3.1 XQuery grammers to implement client-side applications which run in XQuery is a shorthand for XML Query Language. It has the Web browser. With GWT, programmers can program in been a W3C recommendation since January 2007 [4]. Orig- Java and compile their code to an AJAX application. Hence, inally, it was designed as a query language to query and programmers no longer need to worry about browser incom- transform XML data natively. By now, it has evolved to a patibilities, and a lot of JavaScript inconveniences such as general purpose programming language that can read, up- errors (type mismatch, etc) are caught by the compiler at date, and transform any kind of data (including, of course, compile-time instead of been caught at runtime. Further- XML). XQuery is a functional programming language, and more, GWT programmers can be supported by the same it is Turing complete. IDE tools as regular Java programmers, e.g. Eclipse. XQuery is a super-set of XPath. That is, any valid XPath One big advantage of GWT is that GWT blurs the dis- expression is also a valid XQuery expression. Hence, there is tinction between the presentation layer and the“middle-tier” no need to embed XPath into XQuery in the way it is done of an application: in principle, GWT enables the movement for JavaScript. Like XPath 2.0, XQuery uses an extended of code between these two tiers in both directions based on XML Data Model [7]: The XQuery 1.0 and XPath 2.0 Data technology trends. As described in Section 6, this is an im- Model. XQuery is strongly typed, yet flexible because data portant feature. Our work on an XQuery plug-in facilitates can be typed as “untyped”. In particular, XQuery can na- the same feature because XQuery also runs in the middle-tier tively process (untyped) Web pages. and (with the help of the plug-in) in the presentation layer. XQuery has a broad functionality, covering simple ex- In fact, XQuery runs on all three application tiers (including pressions such as constants, variables, and comparisons to the database), facilitating even more code movement. complex expressions for database queries, transformations, and information retrieval. For example, the FLWOR (pro- 2.4 Gears nounced “flower”) expression corresponds to the “SELECT Gears is an offering from Google in order to enable the de- FROM WHERE” statement in SQL, for example: velopment of full-fledged applications inside the Web browser. For instance, Google Apps (i.e., Google’s competition to Mi- for $x at $i in crosoft’s Office products) were developed with the help of doc("bill.")/paymentorder/paymentorders Gears. Among the features provided by Gears are support let $price := $x/price for inside the browser. With the help of this fea- where $x/name ftcontains "computer" ture, browser-based applications can run even if the client is return

  • not connected to the Internet. Furthermore, such a client- {$x/name} side database improves performance if fine-grained changes {data($price)} are made, e.g., to a text document.
  • Again, our work on enabling XQuery in Web browsers In order to support information retrieval, XQuery also targets in exactly the same direction as Gears. XQuery can involves full-text search [3] as shown below. also be used to facilitate client-side database access. Fur- for $b in /books/book thermore, our XQuery plug-in naturally co-exists with the where $b/title ftcontains Gears browser extensions. ("dog" with stemming) ftand "cat" 2.5 Flex return $b/author Flex is a popular tool in order to develop graphical user This example finds all authors of all books the title of interfaces for Web browsers. It is based on a programming which contains the word “cat”, as well as the word “dog” or language called ActiveScript which is similar to JavaScript. a word with the same stem. Just like any other functional programming language, an set $b := //book[title="starwars"]; XQuery expression is evaluated in a context. The context insert node $b into doc("lib.xml")/books; contains functions, namespaces, schemas, and variable bind- set $b := doc("lib.xml")//book[title="starwars"]; ings. For instance, the expression $x will be evaluated using insert node 6 movies into $b; } the context; if the variable $x is not defined in the con- This program is a block, the expressions of which are exe- text, then an error is raised as part of the evaluation of cuted sequentially. First, a variable $b is declared. $b is ini- this expression. Otherwise, this expression is evaluated to tialized to a book which is copied and inserted into lib.xml. the value of $x as defined in the context. Likewise, func- Then $b is set to the newly inserted node in lib.xml (it can tion invocations are evaluated according to the definition of be read because this instruction sees the side effect of the the functions in the context. The XQuery recommendation insertion). Finally, a comment is inserted into the book. already defines the “http://www.w3c.org/xquery-functions” The XQuery Scripting Extension is still in its early stages namespace and a whole function library in this namespace of standardisation but first implementations already exist. (e.g., sum, distinct-values, etc.) [9]. Extending the context with new browser-specific namespace, schema, and function 3.4 REST and Web Services Support definitions is an important part of integrating XQuery into The W3C is also currently standardising extensions to the Web browser (Section 4.1). XQuery in order to effect REST and Web Service calls and 3.2 XQuery Update Facility in order to make sure that XQuery modules and functions can be called directly with the help of REST or Web Ser- XQuery 1.0 is side-effect free, i.e., an XQuery expres- vice calls. With the current proposal discussed inside the sion cannot alter an XML node. Obviously, side effects W3C working group, for instance, a Web service could be are needed for AJAX-style programming in order to change defined using the following XQuery code (i.e., a Web service the Web page based on the actions of a user. The XQuery corresponds to an XQuery module): Update Facility [6] has been designed to extend XQuery in order to facilitate updates to XML nodes. For instance, module namespace ex="www.example.ch" port:2001; the XQuery Update Facility enables to insert new elements, declare option fn:webservice "true"; delete elements, rename elements and replace the content declare function ex:mul($a,$b) {$a * $b}; of an element. Since DOM is an API for XML data, the The following XQuery code could be used in order to call XQuery Update Facility can be used naturally in order to the Web service defined above: update Web pages; i.e., data stored behind a DOM inter- import module namespace ab="www.example.ch" face. The XQuery Update Facility has been a candidate at "http://localhost:2001/wsdl"; recommendation since August 2008. replace value of node The following contains two example updates, an insert of //input[@name="textbox"]/value a new book into a library and the update of the price of a with ab:mul(2,5) book: Support for REST, which seems to be more popular on the open Web, goes along the same lines. insert node into doc("library.xml")/books, replace value of node 4. XQUERY IN THE BROWSER doc("bill.xml")/bill/items[@id="computer"]/price The previous section showed that XQuery has all the in- with 1500 gredients needed to develop Web-based applications. It pro- cesses XML data natively, it is declarative, yet powerful All modifications are performed once the expression is en- enough for complex applications, and it supports remote tirely evaluated: there are no side effects until the end and calls via REST and Web Services. This section presents ex- instructions do not see the side effects of former instructions. tensions to XQuery so that XQuery becomes a viable option 3.3 XQuery Scripting Extension for AJAX-style applications in the Web browser. Further- more, it shows how XQuery can be embedded into HTML The XQuery Scripting Extension [5] is an extension of pages for execution inside the Web browser. XQuery and the XQuery Update Facility. With this exten- sion, XQuery becomes a full-fledged programming language 4.1 Overview which can be used in order to program any kind of applica- Like JavaScript, we propose to embed XQuery scripts into tion. The main difference as compared to XQuery and the HTML documents with a In order to retrieve certain properties (e.g., a frame, a location), it is possible to navigate through these elements Again, the XQuery code is embedded into a ("at"|"behind") ExprSingle
    First Name:
    EventDetach ::= "on" "event" ExprSingle

    Suggestions:

    "at" ExprSingle "detach" "listener" QName First, the namespace prefix ab is bound to a web service. EventTrigger ::= "trigger" "event" ExprSingle When the user types in the text box, local:showHint(value) "at" ExprSingle is called (onkeyup attribute of the input element). If the The “behind” construct, used for asynchronous calls (e.g., textbox is not empty, then ab:getHint($str) is called asyn- of Web services), is explained later in section 4.4 chronously. In this call, the important new concept is the “behind”construct which binds the event to the evaluation of 4.3.2 Event Node the expression, rather than to its result. As a consequence, When an event occurs, the listener is called and receives an event is triggered when the computation of the result is two parameters $evt and $obj. The first parameter is an completed; i.e., when the remote call returns with a result. XML element which contains information about the event, Furthermore, the call is non-blocking; i.e., asynchronous. for example whether the alt key was pressed, which mouse The user keeps control of the user interface. Every response button was used... the same information which is available or signal which is returned from ab:getHint, triggers a call in an Event Object in the DOM [10]. The second element is to the my:stateChanged function. For instance, if the sig- the DOM node where the event occured. nal indicates that the response has arrived, then the hint is As in the DOM, there are several event properties which displayed on the webpage. can be queried: $event/target, $event/type, $event/altKey, 4.5 CSS $event/button... so that one can adapt the behaviour of the listener: Another important aspect of browser programming is han- dling stylesheets. Stylesheets could be actually manipulated declare function local:listener($evt, $obj) { directly using XQuery by modifying the style attribute of an if($evt/button=1) (: do something :) element (which is a string containing the list of style prop- else (: do something else :) erties and their values), with an updating expression. }; An alternative way is to introduce additional syntax as on event "onclick" at html//input[name="submit"] this is such a common case. This has the additional advan- attach listener local:listener tage of not integrating the style properties in the XML tree as children of the style attribute, which would not be correct In this example, when the user clicks on the submit but- XML. ton, my:listener is called and receives an event node as well For example, one modifies the style of an element with: as the location node as parameters. It reads the event node and does something if the user clicked with the left button, set style "border-margin" something else if she clicked with the right button. of //table[@id="thistable"] to "2px" 4.4 AJAX And one can query its style with: In JavaScript, the XMLHttpRequest object allows to make { declare variable mystring as xs:string; asynchronous calls, at a low-level. In XQuery, we use the set $mystring := get style "border-margin" event syntax extension to implement asynchronous calls. of //table[@id="thistable"]; } The following example is the XQuery version of an AJAX This is associated with the following grammar extension: example given at [1]: ExprSingle ::= (all existing options) and XQuery. JavaScript is used to run Google Maps and
    Shopping cart
    communicate with the Google server using AJAX. XQuery
    in the browser (with our plugin) is used in order to initi- <% // Code establishing connection ate REST calls to the diverse weather services and integrate ResultSet results = the results returned by the weather services. Furthermore, statement.executeQuery("SELECT * FROM PRODUCTS"); XQuery is used in order to search for Web cams at the loca- while (results.next()) { tion of interest. The interesting aspect of this co-existence out.println("
    "); of JavaScript and XQuery in the browser is that, in this String prodName = results.getString(1); application, code written in both languages listens to the out.println(prodName); same events. For instance, if the search button in Google out.println("
    "); } results.close(); XQuery. All major (relational) database vendors already // Code closing connection %> support XQuery and XQuery is a popular language in several middleware products. With the help of XQuery, it is thus In this example, the business logic is developed using JSP possible to achieve flexible and largely simplified application (Java nested into HTML). JavaScript is executed on the architectures, thereby possibly eliminating the need for data client, with embedded XPath. The server-side code even marshalling and some layers in the application stack. contains SQL. In order to make XQuery suited for the browser, XQuery If this application had been developed with XQuery only had to be slightly extended. Most importantly, support for from scratch, it would look like the following XQuery ex- events had to be integrated in order to be able to implement pression: reactive and asynchronous user interfaces. Other than that, plore and quantify the benefits of developing Web applica-
    Shopping cart
    tions using XQuery. For instance, we would like to study
    { the performance of XQuery in the browser as compared to for $p in doc("products.xml")//product JavaScript. A second important avenue for future work is to
    {$p/name} port the plug-in to Firefox and other Web browsers; we are currently working on this. Furthermore, we are working on
    tools for XQuery development (http://www.xqdt.org), like }
    a debugger, performance profiler and Eclipse support. In the long run, we expect the availability of tools and libraries for XQuery to surpass those available for JavaScript. The database is mapped to an XML document with the URI given as parameter to doc(). A FLWOR expression in- 8. REFERENCES serts the products. The events are registered for all buttons with a single instruction. The entire code, client-side and [1] Ajax suggest example. http://www.w3schools.com/ server-side (even the HTML tags) is XQuery. ajax/ajax_example_suggest.asp. This shows that using XQuery for everything simplifies [2] XQIB Samples. http://www.xqib.org/samples. considerably the Web application. XQuery can be used for [3] S. Amer-Yahia, C. Botev, S. Buxton, P. Case, database access (instead of SQL), to define the application J. Doerre, M. Holstege, J. Melton, M. Rys, and logic (instead of C# or Java) and inside the browser (instead J. Shanmugasundaram. XQuery 1.0 and XPath 2.0 of JavaScript). Furthermore, this example shows that an Full-Text 1.0. XQuery-only implementation can require fewer lines of code http://www.w3.org/TR/xquery-full-text/. and avoid the technology jungle. [4] S. Boag, D. Chamberlin, M. Fernandez, D. Florescu, Another example that demonstrates how XQuery can re- J. Robbie, and J. Sim´eon. XQuery 1.0: An XML duce the number of lines of code is given on [2]. The mul- Query Language. http://www.w3.org/TR/xquery/, tiplication table demoed on that site requires 77 lines of jan 2007. JavaScript code or alternatively only 29 lines of XQuery [5] D. Chamberlin, D. Engovatov, D. Florescu, G. Ghelli, code. J. Melton, and J. Sim´eon. XQuery Scripting Extension 1.0 Working Draft. 7. CONCLUSION http://www.w3.org/TR/xquery-sx-10/. [6] D. Chamberlin, D. Florescu, and J. Robbie. XQuery The browser today is not only a rendering tool, but has Update Facility. become a programming environment. The most popular http://www.w3.org/TR/xquery-update-10/. client-side programming language, JavaScript, is geared to- wards this purpose. This paper showed that XQuery is also [7] M. Fernandez, A. Malhotra, J. Marsh, M. Nagy, and a viable candidate to program the Web browser. Just like N. Walsh. XQuery 1.0 and XPath 2.0 Data Model JavaScript, XQuery is a full-fledged programming language (XDM). http://www.w3.org/TR/xpath-datamodel/. with many features for processing and integrating data on [8] P. L. H´egaret and T. Pixley. Document Object Model the Web. In addition, XQuery has the advantage of be- (DOM) Level 3 Events Specification. http://www.w3. ing declarative and therefore better optimisable. In partic- org/TR/2003/NOTE-DOM-Level-3-Events-20031107/. ular, XQuery can process XML data declaratively in order [9] A. Malhotra, J. Melton, and N. Walsh. XQuery 1.0 to query and manipulate the DOM that represents a Web and XPath 2.0 Functions and Operators. page in the browser (e.g., HTML tables) or results of REST http://www.w3.org/TR/xpath-functions/. calls. Another reason to consider XQuery in the browser [10] N. C. Zakas. JavaScript for Web Developers. Wrox, is to avoid the technology jungle found in many applica- Wiley Publishing, Inc., 2005. tions today: XQuery runs in all tiers (database, middle- ware, and Web browser) and therefore whole applications can be implemented using a single programming language,