After thinking about how I could integrate the old documentation into docbook, I decided to change the gendoc script. Instead of generating XHTML, I've changed it to generate docbook. This has also the advantage that I can still use my own XML structure, which is less verbose then docbook XML. So no docbook XML in the source code, the docbook XML is generated by my script.
I also removed the templates. Instead I use E4X. E4X makes it possible to use native XML in JavaScript. It's very powerful, and it can be used as templates for generating XML and XHTML. Look at the the code of gendoc.js to see GLUEscript and E4X in action.