first read this:
Sitemap.xmap:
<map:pipeline internal-only="true">
<map:match pattern="GenTransSer">
<!-- Generate/Transform/Serialize -->
<map:generate src="{request-param:GenSrc}"/>
<map:transform src="{request-param:TransSrc}"/>
<map:serialize type="xml"/>
</map:match>
</map:pipeline>
XML/XSP File:
<cinclude:include src="cocoon:/GenTransSer?GenSrc=source.xml&TransSrc=transform.xslt"/>
Generator Java source
Write a Class which extends from AbstractGenerator. In the method generate() use the xmlConsumer (this.xmlConsumer) to create SAX-Events.