Summary
DataDirect recently released XQuery 2.0, supporting the latest W3C XQuery standard, and providing an implementation of the XQuery for Java API (XQJ) as well. XQuery 2.0 can query multiple data sources—such as a database, XML documents, and Web services—simultaneously, and present a unified view of the results.
Advertisement
DataDirect recently released XQuery 2.0, supporting the latest version of the W3C's XML query language standard.
Jonathan Robie, DataDirect's XQuery technical lead, who is also co-author of the XQuery standard, told Artima that XQuery is useful not only to access a relational database via an XML interface, but also to integrate data from diverse data sources. "A lot of developers tend to think that data [in an enterprise application] is stored mostly in relational databases. But you increasingly have to integrate data from relational databases with data from other sources, such as flat files, XML documents, or EDI [electronic data interchange] sources, as well as Web services."
While the XQuery language does not handle such data integration, DataDirect's XQuery tool is designed to do just that. A developer can write one query in the XQuery language and, according to Robie, let the XQuery infrastructure take care of delegating that query to possibly multiple data sources, returning a single result set. Because the results are returned as XML, XML tools can transform those results into another XML format suitable for presentation, such as XHTML.
Robie pointed to one XQuery application that integrates data from an Oracle database and a SalesForce.com CRM system in order to automatically generate proposals to clients. "The pricing and inventory data come from Oracle, but the customer data is in SalesForce. They wrote an application that combines data from those data sources via a single XQuery, and then generates the proposal, also via XQuery. They do this over the Web, and can create such proposals even from a PDA."
Although developers could write such distributed queries by hand and then stitch together the results into a unified presentation, using a specialized XQuery tool can yield better performance, according to Robie. "When you have many such queries, you may spend time to optimize a few that you think are most important... The XQuery tool, though, will try very hard to optimize all your queries," and may do a better job overall than a developer could with hand-written queries, notes Robie.
Although JDBC is not be visible to a developer working with XQuery, at the end of the day DataDirect's XQuery tool communicates with a database server via JDBC, taking advantage of the company's experience in developing high-performance JDBC drivers. Robie noted that highly optimized database drivers can provide an additional performance boost, for instance, by better managing network traffic between a database server and an application server.
In addition to the W3C XQuery standard, DataDirect's product also supports the XQuery for Java API (XQJ), JSR 225. XQJ provides a Java-centric API for XQuery and, according to the JSR 225 specifications, "relates to XQuery in the same way JDBC relates to SQL." While JDBC 4 supports the SQL XML data type, it still requires SQL to interact with XML data in the database. XQJ, by contrast, allows XQuery statements to be issued not just to query XML stored in the database, but to obtain XML results over any database object.
XQuery, as implemented in DataDirect's product, seems to solve the problem of integrating data from multiple data sources into a single query result. A more conventional way to perform such integration would be to invoke the various component services individually, and then to aggregate the results unto a unified presentation.
How often have you encountered a need for such data integration-style queries? And to what extent do you think the XQuery approach can make that task easier?