Add stuff so that the xml body writer can grok this.
Better parse the query and implement some of the aggregating functions.