XQuery is an XML technique that unfortunately doesn’t get as much attention as it deserves.
Part of the reason is that there are not many XQuery implementations, many use Java, some have ugly licenses and others are incomplete. One that’s written in C with libxml2, Mozilla-licensed and pretty complete is MonetDB XQuery, based upon the MonetDB RDBMS.
A special thing about MonetDB is that it is not inherently SQL-based, but supports several front-ends, among them SQL, but also XQuery. Queries in both languages get translated into MIL (MonetDB Interpreter Language), respective MAL (MonetDB Assembler Language) for version 5, which doesn’t yet support XQuery, however.
MonetDB and the XQuery front-end compile (almost) out of the box, but
contain huge .c
-files (up to 5 megabytes) due to code-generation
techniques. Be sure to have enough free RAM when you want to compile
it.
XQuery is a nice language (unlike it’s totally evil bastard brother, XQueryX), reminding of languages like OCaml, Links or XDuce. It’s probably what XSLT always should have been.
I also think XQuery would make a great templating language (I used to template websites with XSLT for years, which can be pretty painful at times.), especially given virtual XML views. (I’m sure one can implement those with MonetDB, but I didn’t try yet.) XQuery templates would allow well-formed XML output by definition and generally ease development.
Unfortunately, most XQuery engines, MonetDB inclusive, are pretty much database-like. MonetDB provides a few helpers to automatically add XML documents you use to its database, but they will be “shredded” into relations nevertheless. This is probably a speed problem if you want to apply one-shot XQuery programs on a large set of documents. If you can store the data in MonetDB anyway, however, I could imagine neat tricks given a light HTTP to XQuery wrapper. MonetDB doesn’t support XUpdate at the moment, so XQuery-based web applications would be read-only for now.
XQuery certainly is a thing that deserves more investigation.
NP: Bob Dylan—Like A Rolling Stone