XQuery simplifies how enterprises can search XML data.
At Congressional Quarterly, an online publication that follows the Washington, D.C., legislative process, Senior Software Architect Hank Hoffman has been swimming upstream.
It's one thing to compile hearing dates, vote counts and committee actions, but it's quite something else to make those data points relate meaningfully to one another. A year ago, Hoffman found what he was looking for in the form of XQuery.
XQuery -- an XML-native query language produced by the World Wide Web Consortium (W3C), a standards development body -- is designed to query and organize XML data.
One of XML's great strengths is its flexibility in representing many different kinds of information from diverse sources, according to the W3C. To make the best use of this flexibility, an XML query language must retrieve and interpret information from these diverse sources.
XQuery is designed to query a broad spectrum of XML information sources, according to the W3C, including both databases and documents. "You can do some very powerful things with just a very few lines of code," Hoffman said, explaining that XQuery makes interpreting and managing masses of XML data a much simpler proposition.
Dive into the Data
Betty Harvey coordinates the Washington, D.C., XML Users Group and is president of the IT consultancy Electronic Commerce Connection Inc. She says XQuery's greatest strength lies in the user's ability to dive into XML data in a way that SQL never allowed.
Suppose a government worker is staring down a massive mountain of legislation and wants to pull out just the bills related to global warming. SQL was never meant to read XML data that way, but XQuery can do it.
The best way to describe the capability, Harvey said, is to think of XQuery as having been raised from the beginning to work within the XML framework. It speaks XML, as it were.
The power of that native query is considerable. Think about a vast repository of medications; should a government agency wish to compile and publish a tract specifically on heart medicines, a single XQuery command could do it, while SQL would have demanded pages of code. "XQuery gives government the ability to search and provide data in ways they hadn't really thought of before," Harvey said.
XML Changes Things
To explain XQuery's role in the realm of data assimilation and interpretation, technologists compare it to SQL, a language used to create and manage data within relational databases. These databases have been the standard means of storing data for years, and SQL is the tool by which that data is manipulated.
Now IT experts say we are moving away from relational databases and migrating to the realm of XML data. For this new era, a new language is needed.
"In the same way that SQL is a very natural language for exploring relational objects, XQuery is a very natural language for querying XML data," said Willie Hardie, vice president of database product marketing at Oracle.
XQuery doesn't necessarily surpass SQL -- the new language was designed with different specifications in mind. "If all you have is relational data, and you want to create tables, SQL is a great language. The problem is that the game has changed," said Jonathan Robie, XQuery technology lead and chief scientist at Massachusetts-based DataDirect Technologies, which makes tools for deploying XQuery within an enterprise.
He's referring to the recent rise of XML as the predominant language driving the Internet and data storage in general -- an evolution that has pushed demand for tools to query and manage XML data. That's where XQuery comes in. More than a decade in the making, XQuery belongs to no one. It's the product of the W3C, which is responsible for its development. Several companies, including Microsoft, IBM, MarkLogic and Saxonica, have moved to commercialize XQuery with diverse tools aimed at easing its implementation.
Robie said there are more than 45 commercial XQuery implementations, which should hardly come as a surprise. Even longtime backers of relational database technology have conceded that XQuery brings a powerful new tool to the XML data-management arena.
In media coverage of the XML 2006 conference held in Boston in December, Oracle's Principal Architect Roger Bamford was quoted as saying XQuery could allow speedy revisions within databases that would otherwise be slow to adjust to the introduction of new data.
Programming Made Simple
XQuery is designed to answer fundamental questions about the management of data, Robie explained. "How do you find stuff in XML? How do you combine stuff from different sources? How do you create new results and new structures? Those are all primitives in XQuery -- things XQuery does naturally."
This could be good news for government IT workers, many of whom have come to rely on XML-driven data systems, which tend to offer easier and more legible access to information than their relational predecessors.
For those IT professionals, XQuery is a labor-saving mechanism. "It processes XML efficiently, by which I mean efficiently for the programmer, because the programmer doesn't have to spend all his time explaining things to the system," Robie said. "The system already understands what XML is, so the programmer writes a lot less code."
This is a big step forward from the relational model. "If you are a programmer working in SQL, and someone has a new data source for you," Robie said, "you are going to crack open some manuals and start studying."
In XQuery, the language assumes everything is XML and leaps forward to execute.
Users say it's relatively easy to acquire a fluency in XQuery basics. Harvey turned to the language to develop an interactive dictionary, and recalls boarding a train not knowing a thing about it. "By the time I took the train to New York, had a meeting and took the train back," she said, "I had a working product that I could give to my client. If you are familiar with XML and XML technologies, it is not that hard to work with."
But even those programmers with significant XML deployments already in place will need to proceed with some caution, as the worlds of SQL and XQuery still overlap. "You still need the right tool for the right job," said Oracle's Hardie. "There may be very clear cases for one and very clear cases for the other, but that will never stop some people from trying to drive a screw with a hammer."
Though XML and XQuery technologies are on the rise, the relational database world is far from over. "We have at least a decade ahead of us," Robie said. "You've got so much expertise, so many people who know what to do with relational databases -- and relational databases still are very efficient at what they do."