Write DOM Session Transformer
Write DOM Session Transformer
Make a DOM object from SAX events and write it to the session.
- Name : writeDOMsession
- Class: org.apache.cocoon.transformation.WriteDOMSessionTransformer
- Cacheable: no.
If you only use the FilterTransformer in combination with the SQLTransformer, you have to query the database each time the user wants to see another part of the result. You can better store the result in the session after the first request and retrieve the result from the session for the subsequent requests. This can be done by using a selector, which checks if the data is available in the session or not.
WriteDOMSessionTransformer can build a DOM starting from a given element (which will be the root of the DOM tree) and store it in the session. If you want to store the result of a query, you have to add following to the sitemap:
<map:transform type="writeDOMsession"> <map:parameter name="dom-name" value="DBresult"/> <map:parameter name="dom-root-element" value="rowset"/> </map:transform>
The transformer will build a DOM tree with rowset as root element and will store it in the session with the name "DBresult".
Note: most of the times, it is not smart to keep the output XML of the SQLTransformer in the session. Check if it is better to do the necessary transformations first, so that you get a smaller DOM, and then put the result in the session. You probably will be able to use the FilterTransformer on the transformed XML also.
The WriteDOMSessionTransformer is a standalone component, you don't need to use it in combination with the SQLTransformer.
Errors and Improvements? If you see any errors or potential improvements in this document please help us: View, Edit or comment on the latest development version (registration required).