Dario Liberman wrote:

>What is the correct way of doing it?
>I am new to cocoon too, but I see here serialization and deserialization
>done perhaps unnecessary.
>

Servlet API is stream-based, thus if you want to use servlet's output, 
you have to parse XML again.


>If the servlet used a DOMXML object to represent the outermost data, and
>then serialized it to give it to cocoon, it is a waste.
>Is there anyway to have the servlet give an XMLobject to the cocoon pipeline
>instead of a character-stream?
>

You can store DOM as request attribute and then forward request 
processing to the Cocoon. In cocoon, you can pick up this DOM object and 
generate SAX out of this into the pipeline, using something similar to 
SessionDOMGenerator.

Instead of forward() in the Servlet it is also possible to write a 
ServletFilter.
Instead of DOM, it is possible to use Cocoon's XMLizable interface.


>In my case, I am used to WebMacro, that is similar to Velocity from apache.
>In this architecture (more or less), the servlet receives a request, and
>then processes an action (like searching something in the database) and then
>puts objects in a hashtable (like a collection of javabeans representing the
>query result) and then invokes a template. The template can use the objects
>passed to the hashtable by specifying $keyname.method() for example. It has
>primitive logic directives as iteration, if-then-else, and a set statement
>in order to modify variables (this way you are forced to code well, since
>most of the logic must be in a java class, not in the template). This output
>then can be sent to the response stream, or to a file or to wherever you
>like (but 99% of the time you set it to the response).
>
>I like this architecture, and I would like to mix it with cocoon. So I
>suppose that instead of WebMacro, I should be doing similar things with an
>xsp, so that instead of a stream of characters I get as output an XMLobject
>to introduce into the pipeline.
>
>Does anybody have a simple starter example of how to do this? Because I like
>to decide the final pipeline (decide the template) from the servlet. As far
>as I could see, the usual way is to have a fixed pipeline map.
>
>Also, I need to get hold of the final xmlobject from the pipeline (instead
>of serializing it to the response) since I have to put this xml in a SOAP
>message as the final result (not a webbrowser).
>

Is it SOAP request to other server? Cocoon can do this. Or, you can use 
SourceWritingTransformer, or write own transformer or serializer.


>So what I need cocoon to be, is an invisible module that I put objects to it
>in some hashtable as input
>

Use request's attributes to pass input data.


> and a template name (or map ref, as you like),
>

URI is a "template name".


>and gives me magically as output (after a pipeline of transformations with
>automatic-caching, etc) a nice XMLobject.
>

SessionDOMTransformer can do this. Also, see SourceWritingTransformer.

Vadim


> Then with it I do what I like (for
>example put it in a soap message response/request or even put it back in a
>cocoon-pipeline of transformations get yet another xmlobject).
>
>
>Perhaps I am lost, since I managed to make cocoon2 work just today, on my
>tomcat 4.1.2 container on jdk1.4 I was told to look for a manifest file
>entry problem or rather unpack the war (I went with the second choice and
>was just fine). Thanks to Vadim!!
>http://www.mail-archive.com/cocoon-users@xml.apache.org/msg18532.html
>
>Well, I hope someone did this style of programming.
>
>Salutes,
>Dario.
>
>  
>
...



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to