...I am more than willing to help. What should I do ?
See this thread http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108204436515664&w=2 for some discussion and ideas about this.
I think the following steps would be enough to allow the GroovySQL/GroovyMarkup stuff to be usable:
-update the groovy lib to the latest one in the BSF block
-provide a way for Groovy scripts (running in the BSF block's ScriptGenerator) to receive a Connection or Datasource from the Cocoon connection pools
-in the groovy script, create an SQL object which uses this connection
It might need to be optimized later on (precompilation, dedicated Groovy block instead of BSF, etc) but that would be a good start!
Ideally, any connections used in the groovy script should be released by the ScriptGenerator/ConnectionProvider, to keep the scripts as simple and safe as possible.
For now, there is an example using groovy markup in the BSF block samples (src/blocks/bsf/samples/generator/helloGroovyMarkup.gy).
Off the top of my head, a generator script using GroovySQL and GroovyMarkup could look like:
import groovy.xml.SAXBuilder import groovy.sql.Sql
contentHandler = bsf.lookupBean("contentHandler")
xml = new SAXBuilder(contentHandler)connectionProvider = bsf.lookupBean("connectionProvider")
sql = new Sql(connectionProvider.getConnection("myconnection")) // didn't check syntax here
contentHandler.startDocument()
sql.queryEach ("select * from person") { person |
xml.customer(id:person.id, type:'Customer', name:person.firstname + " " + person.lastname)
}
contentHandler.endDocument()
Hope this helps! -Bertrand
