<p>I am looking for a tool that can serialize and/or transform SQL Result Sets into XML. Getting dumbed down XML generation from SQL result sets is simple and trivial, but that's not what I need.</p>

<p>The solution has to be database neutral, and accepts only regular SQL query results (no db xml support used). A particular challenge of this tool is to provide nested XML matching any schema from row based results. Intermediate steps are too slow and wasteful - this needs to happen in one single step; no RS->object->XML, preferably no RS->XML->XSLT->XML. It must support streaming due to large result sets, big XML.</p>

<p>Anything out there for this?</p>

Not that I know of.  I would just roll my own.  It's not that hard to do, maybe something like this:
```
```
#!/usr/bin/env jruby

import java.sql.DriverManager

# TODO  some magic to load the driver
conn = DriverManager.getConnection(ARGV[0], ARGV[1], ARGV[2])
res = conn.executeQuery ARGV[3]

puts "<result>"
meta = res.meta_data
while res.next
  puts "<row>"

  for n in 1..meta.column_count
    column = meta.getColumnName n
    puts "<#{column}>#{res.getString(n)}</#{column}"
  end      

  puts "</row>"
end
puts "</result>"
```
```
Disclaimer:
I just made all of that up, I'm not even bothering to pretend that it works.  :-)