Getting a grip on XQuery

07.12.2006
XML seems unstoppable. On the Web, this general-purpose document display language is rapidly replacing HTML. In the office, Microsoft Corp. and OpenOffice have both moved to XML document formats. Even the big database vendors are turning their databases into relational/XML hybrids. That latter effort should get a boost by the end of the year, when XQuery, the XML counterpart to the conventional SQL database language, is expected to be become an officially recommended standard of the World Wide Web Consortium.

Jonathan Robie, XQuery technology lead at DataDirect Technologies, a subsidiary of Progress Software Corp., is one of the prime movers behind the XQuery standard. He spoke with Computerworld about XQuery's importance and its effect on business IT users.

How would you explain the importance of XQuery to an IT manager or CIO? If you've got objects, you want an object-oriented programming language. If you've got relational tables, you want SQL. If you've got XML, you want an XML programming language. You could mix and match and, for instance, use Java to program a relational database. But you would write a lot more code, it's a lot more complicated, and you end up fighting the data you're working with. For data integration, XQuery also has a unique advantage. Usually, you have to learn a new [application programming interface] for every different data source you work with. Then you have to do a lot of programming to integrate the data and bring it together. XQuery gets rid of all that. It lets you query everything as if it were XML and create an XML result. You don't have all of those APIs cluttering everything up.

What are some real-world implications of that? Could you enable more powerful searching of the Web, more powerful than Google today, for instance? There is a full-text search standard for XQuery, but most XQuery implementations now are not about full-text search. I think of XQuery more in terms of when you have a bunch of disparate data sources in your enterprise -- some databases, some configuration files, some programs -- and you want to integrate all that data for Web services or Web sites.

So XQuery might let you eventually sidestep some of the current data integration, data cleansing or master data management products out there today? Yes, absolutely. People are taking procedural and pipeline approaches to getting data together. That involves a bunch of middleware or Web services interfaces. A simple declarative query is what you'd really like. You can bypass many steps, save on massive amounts of code and avoid potential mistakes.

Is XQuery suitable for real-time data integration? That absolutely depends on your implementation, but yes. To solve such a problem today, you might be using a hodgepodge of things, like JDBC, SQL and some XML API like DOM, with all of this procedural code in between. Because you're talking to multiple systems and using procedural code, you can't optimize this. But XQuery is declarative, meaning a good system can take that stuff and optimize it against different data sources in ways you wouldn't think to.