I'm convinced that Xquery is somewhat the non-elegent child of the xml family of technologies. Every single technology from XSL to Xpointer, Schema to XMLencryption seem to pick part of the puzzle and do that bit very well. So you can forgive me for thinking Xquery would only be useful for querying data from a xml database, somewhat the SQL of the XML world right? Nope, in actual fact its not only SQL but also PHP and the XML doesn't even have to be in a database at all. The crossovers with XSL is quite shocking for such a elegent family. Fear not, Xpath forms a large part of Xquery meaning us XSL lovers can jump straight in and feel a little at home with its strangely non-xml syntax, I actually quite like writing xml to create/transform xml. And if things get a little too weird in Xquery land, you can run for the beach by telling Xquery to do a XSL transformation on a tree of data instead.
Although it doesn't quite fit, its actually darn powerful and beats messing with XSP or other templating languages. For example, in about 6 easy to understand lines of Xquery, I was able to pull down a XHTML document, rip off its head element and append the body inside a ATOM feed. I could do the same with XSL but it would be much more lines and the way Xquery is setup, it seems to make more sense. One of the big issues people have with XSL is that it doesn't know anything about its environment. So for example calling the present time would require looking up a webservice or some other external logic like PHP, XSP, JSP, etc. Well with Xquery, you get all that type of logic which you could even pump into a XSL transform.
I'm learning Xquery right now mainly through Exist DB and this nice wikibook, which I converted to PDF using the wikibook system for offline reading and reference on my Ebook reader.