XQuery takes center stage in eXist database
Maturing open source database proves excellent handler of XML content
eXist is an open source XML database that has matured into an impressive XML content search and storage system. In eXist, unlike in Apache Xindice or Berkeley DB XML, XQuery plays a central role, but eXist is not quite as scalable as these databases. Nevertheless, its easy installation, slick documentation, and comprehensive API set make eXist an excellent choice for anyone who wants to get a powerful XML database up and running quickly.
A pure Java application, eXist is available as a JAR or WAR (Web Application Archive) file. I recommend the JAR file installer, because it sets everything up (including the Jetty servlet container and eXist source) with a single command line.
After the eXist database engine is started, you begin by navigating your browser to its HTML interface. You’ll swear you’ve been forwarded to the eXist home page, but it’s actually a kind of “live documentation” eXist hosts through its Web server. Very nice. For example, one tutorial automatically downloads and installs external documents at the click of a button, then demonstrates XQuery queries on the installed documents. The tutorial even provides a text box in which you enter and test your own queries, a feature I found so handy that I’ve begun using it to experiment with XQuery.
eXist also installs an administration application. The application’s upper pane displays a list of current resources (collections and documents), and the lower pane is a scrolling text window into a command-line shell. In the upper screen you select a resource and view or modify the access permissions granted to users of that resource. In the command-line shell you execute various commands for modifying collection contents (such as adding or removing documents).
Earlier versions of eXist used a relational database back end, but the current version is a native XML database optimized to handle XML. Queries are accelerated with the help of indexes that eXist invisibly creates for its important internal components. The system builds B+tree indexes for elements and words, and it creates indexes for collections (for mapping collection paths to collection objects) and DOM objects (for rapid location of a document’s nodes).
eXist provides quite an array of mechanisms for manipulating the database. The REST (Representational State Transfer)-style interface allows you to access data through simple HTTP requests. You can also perform more elaborate operations with POST requests, which expect an XUpdate document or a query request as an XML fragment in the content of the request.
Programming access is available through the XML:DB Java API, to which eXist adds three extra services. The UserManagementService allows you to manage users and permissions; DatabaseInstanceManager allows you to shut down the database; and IndexQueryService provides access to eXist’s automatically created indexes.
Of course, the most convenient interface into XML data is via eXist’s WebDAV support. Collections show up as folders, documents as documents, and you can create, add, and remove content with drag-and-click ease.
What really opened my eyes is that eXist proves that XQuery -- to which eXist adds several powerful extensions -- is not just for querying. It’s a full-blown functional language powerful enough to drive entire Web sites.
eXist’s next release, expected this summer, will add a sort of XQuery equivalent of stored procedures, so you’ll be able to store and execute XQuery code directly in the database. The next release will also include new index types for improved queries.
eXist is a worthwhile study in the power of XQuery, with excellent tutorials and documentation. It’s an open source gem.
Read more about data management in InfoWorld's Data Management Channel.