cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrzej Jan Taramina" <>
Subject New ReadDOMTransformer/WriteDOMTransformer available.
Date Sat, 18 Oct 2003 22:31:31 GMT
The existing Read/WriteDOMSessionTransformer was limited to reading/writing 
to sessions only.  I didn't really like this behaviour, since there are times 
you only want to store stuff for the duration of a request, and thus not have 
it get serialized to a persistent store (eg. by Tomcat) if you forget to 
invalidate the session or delete the DOM object (deletion currently being 
problematic with Cocoon).

So I wrote new ReadDOMTransformer and WriteDOMTransformer classes that take 
an extra parameter specifying whether to read from/write to the session or 
the request instead.  Default is to write to a session to stay more or less 
compatible with the older versions.

Usage notes for the WriteDOMTransfomer:

 * Make a DOM object from SAX events and write it to the session or request.
 * This transformer is based on the original WriteDOMSessionTransformer, but 
has been made
 * consistent in it's parameter naming and internal structure with the 
 * ReadDOMTransformer.
 * Usage in sitemap:
 *    <map:transform type="writeDOM">
 *      <map:parameter name="write-to" value="request">
 *      <map:parameter name="attribute-name" value="companyInfo">
 *      <map:parameter name="dom-root-element" value="companies">
 *    </map:transform>
 * Where:
 *   write-to specifies whether to write to the session or request (default: 
session )
 *   attribute-name is the name for the DOM object in the session or request
 *   dom-root-element is the trigger that will be the root element of the DOM

Usage notes for the ReadDOMTransfomer:

 * With this transformer, an object that is stored in the session or request, 
can be inserted
 * in the SAX stream at a given position, using usual <xsp:expr> rules.
 * Object can be DOM Node, XMLizable, or any other object supported by 
 * This transformer is based on the original ReadDOMSessionTransformer, but 
has been made
 * consistent in it's parameter naming and internal structure with the 
 * WriteDOMTransformer.
 * Usage in sitemap:
 *    <map:transform type="read-DOM">
 *      <map:parameter name="read-from" value="request"/>
 *      <map:parameter name="attribute-name" value="companyInfo"/>
 *      <map:parameter name="trigger-element" value="company"/>
 *      <map:parameter name="position" value="after"/>
 *    </map:transform>
 * </pre>
 * Where:
 *  read-from specifies whether to read from the session or request (default: 
session )
 *  attribute-name is the name of the object in the session/request
 *  trigger-element is the element that we need to insert the SAX events
 *  postion is the actual place where the stream will be inserted, ie before, 
after or in
 *  the trigger-element

And you need to add the transformer entries to your sitemap as follows:

<map:transformer name="writeDOM" 

<map:transformer name="readDOM"  

Because WriteDOMTransformer parameters were made consistent with the 
it's not a direct drop-in replacement for the older 
WriteDOMSessionTransformer (it now uses the "attribute-name" parameter 
instead of the prior "dom-name parameter" which was misnamed,

Anyhow....available in source for any/all who might want it.

Maybe a Cocoon submitter can take the code and include it in the upcoming 
2.1.3 release?


Andrzej Jan Taramina
Chaeron Corporation: Enterprise System Solutions

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message