Yeah, I'm a little behind on XQuery, as I haven't been doing a lot of XML related work for the past couple of years, but I'm just now starting to play in that world again. I have some some reading up on XQuery recently and it's looking like neat stuff. I didn't realize that it was in any way a potential substitute for XSLT though. Guess I have some more studying to do...
That thing you are looking for is XQuery (http://www.w3.org/TR/xquery/) and it is fantastic.
Don't be fooled by the name: it can produce content, too.