An XQuery Servlet for RESTful Data Services

Jonathan Robie


Many servlets do nothing more than integrate data from multiple sources to create an XML or HTML result. As an XML-oriented data integration language, XQuery is a particularly simple, productive, and efficient way to do this task. In this presentation, I show a servlet that provides a REST interface to any XQuery that a developer places in a secure deployment directory on an application server, then demonstrate the development of data services by writing XQueries that access XML, relational, and flat file formats such as EDI to create complex XML and HTML results, then copying to the deployment directory. In this environment, each XQuery inherently defines a REST interface. I will develop queries by dragging and dropping from relational, XML, and EDI (or other flat file formats) into the text of an XQuery, using a standard XQuery GUI environment, then copy queries into a deployment directory, and invoke them using a web browser. The servlet will run under Apache Tomcat. XML data is queried directly using XQuery, with an implement that uses document projection and streaming so that large XML files can be handled efficiently. Relational data is queried by converting XQuery to efficient SQL, executing the SQL, and returning the results as XML. EDI and flat file formats are queried by converting them physically to XML and querying them using the same document projection and streaming techniques used for querying XML documents. The REST interface to a query consists of the name of the servlet and URI parameters that identify the name of the query and the query's external variables. A query may also use the variable $content, which is bound to the content of an HTTP request if present. Preparing queries dramatically improves performance. Each time a query is invoked by a client, the servlet does the following: (1) If this query has been prepared and is up-to-date, the prepared query is used. If the query has not been prepared, or a more recent version of the query exists in the deployment directory, the query is prepared. (2) All URI parameters are bound to the query as external variables. (3) The query is executed, and query results are returned to the client.


Bibliography Navigation: Reference List; Author Index; Title Index; Keyword Index

Generated by sharef2html on 2011-04-15, 02:00:41.