XQueryP: An XML Application Development Language
Don Chamberlin, Michael J. Carey, Mary Fernández, Daniela Florescu, Giorgio Ghelli, Donald Kossmann, Jonathan Robie, Jérôme Siméon
Abstract
- Operating on XML data with a traditional programming language leads to a serious "impedance mismatch" because the type system of the programming language is not based on XML
1. Introduction
- modern business applications use XML to represent data that is heterogeneous, or sparse, or has an intrinsic order
- XML data from other applications or from a database must be transformed into programming language objects before it can be operated on by the business logic
- we explore the possibility of extending XQuery to implement the business logic of XML-based applications, much as SQL has been extended for relational applications
- the case for extending XQuery in a similar way is perhaps stronger due to the large mismatch between programming language type systems and XML Schema, which includes features such as complex types, attributes, multiple kinds of inheritance, and recursive hierarchies
- Our design goal is to find a small set of upwardcompatible extensions to XQuery with Update that can enable the development of XML-based applications
2. Sequential Execution, Blocks, and Assignments
- XQuery, like SQL, is a functional language in which data flows from one expression to another by function calls and returns, without side effects
- XQuery 1.0 has no notion of state, and no defined order for the evaluation of expressions except where one expression serves as an operand of another
- In XQuery with Update, a given query may contain several updating expressions, but each of these expressions operates on the data in its initial state, and all updates are held in a pending list and applied together at the end of query processing
- Expressions are evaluated in a well-defined order, and the side effects of each expression are visible to the next expression to be evaluated
3. Control Flow
- XQuery 1.0 defines constructs for conditional branching (if-then-else) and iteration (the forclause of a FLWOR expression)
4. Exception Handling
- In XQuery, all types of values have symmetric constructor and deconstructor operators, with the exception of the error value
- QName error code, an optional string description, and an optional value that can be used to encapsulate query state when the
error is constructed
- No XQuery expression can take the error value as input--therefore when an error is raised, control flow returns to the application environment
- Each catch clause contains a NameTest (for identifying a type of error), three optional variables (to be bound to the three parts of the error), and a return expression (for handling the error)
- The default clause has a similar structure, except that it has no NameTest because it applies to all types of errors
5. Building Data Structures with References
- In XQuery, this functionality is provided by the element constructor expression, which creates a new element whose content is a sequence of objects
- Constructor expressions are different from other XQuery expressions in that they make copies of their operands
- All other kinds of XQuery expressions return nodes by reference rather than by copy
6. Invoking and Coordinating Web Services
- In order to facilitate the development of Web applications, XQueryP provides the ability to access web services using a service import declaration in the prolog
- This import takes advantage of the natural correspondence between web services and XQuery modules
- XQuery module definition groups together a set of global variables and functions, which can then be imported and used in another module
- The module definition declares a namespace which is shared by the variables and functions in the module
- XQueryP supports service imports, which allow an application to import a web service as though it were an XQuery module
- Because XQuery and WSDL-based web services both rely on XML as a data model and XML Schema as a type system, this import provides a simple interface to web services without the need to generate a complex mapping between XML Schema and a programming language type system such as JAXB
- the service import behaves the same as an XQuery module import that provides access to one or more functions and/or types defined by the web service
- web service operations correspond to XQuery functions, including how function signatures are derived from WSDL descriptions of a web service
9. Conclusions and Future Work
- XQueryP is a proposal for extending XQuery to support development of XML-based applications without relying on a host programming language
- We believe that the proposed language extensions can dramatically reduce the amount of code required to develop web services and other XML applications
- This simplification is made possible by operating on XML in its native data model rather than transforming it into a different
type system
- The XQueryP approach makes it possible to tightly integrate all three parts of an application (storage, logic, and presentation) by basing them all on XML
- One area in which additional work is needed is that of providing mechanisms for XQueryP applications to interact with their external environments