Read DOM Session Transformer
http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Main
User Documentation

Transformers
Overview

Default
XSLT Transformer

Core
Fragment Extractor Transformer
I18n Transformer
Log Transformer
SQL Transformer
Filter Transformer
Read DOM Session Transformer
Write DOM Session Transformer
XInclude Transformer
CInclude Transformer
EncodeURL Transformer
SourceWriting Transformer

Optional
XT Transformer
LDAP Transformer

Read DOM Session Transformer

With this transformer, a DOM-object that is stored in the session, can be inserted in the SAX stream at a given position.

  • Name : readDOMsession
  • Class: org.apache.cocoon.transformation.ReadDOMSessionTransformer
  • Cacheable: no.

Simply transforms a DOM to SAX-events, which can be used further on in the pipeline. Once you stored the result of a query in the session with the WriteDOMSessionTransformer, you can read it again with the ReadDOMSessionTransformer:

     
      <map:transform type="readDOMsession">
        <map:parameter name="dom-name" value="DBresult"/>
        <map:parameter name="trigger-element" value="users"/>
        <map:parameter name="position" value="after"/>
      </map:transform>
     
    

In this example, the SAX-events that came from the DOM tree that is stored in the session with name DBresult will be added after the users element. This means as soon that the transformer encounters the end-element 'users', it will start to generate SAX-events from the DOM tree. There are three possible positions, 'before','in' and 'after':

  1. 'before' means that when the transformer encounters the 'users' element, it will FIRST translate the DOM tree to SAX-events and THEN it will continue to forward the other SAX-events (starting with 'users').
  2. 'in' means that the transformer will forward the startElement event for 'users' and that it IMMEDIATELY starts to generate SAX-events from the DOM-tree. After that, it will continue to forward the child elements of users and then all the other elements.
  3. 'after' means that the transformer starts to generate SAX-events from the DOM-tree just after it has forwarded the end-element 'users'.

The ReadDOMSessionTransformer is a standalone component, you don't need to use it in combination with the WriteDOMSessionTransformer.

Copyright © 1999-2002 The Apache Software Foundation. All Rights Reserved.