cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Antwort: Greetings and question
Date Fri, 10 Oct 2003 14:10:45 GMT


If you post your XML, then you can write a generator which takes the body
of the httppost (your xml) right into your pipeline
transform it as you like and use the html serializer for generating your

package xx.yy.zz;


import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.http.HttpRequest;
import org.apache.cocoon.generation.ServletGenerator;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

 * This generator expects a POST request with a valid XML document body.
 * It feeds the corresponding XML events into the pipeline.
 * @author
public class RSFXmlRequestGenerator extends ServletGenerator implements
       * @see
      public void parameterize(Parameters parameters) throws

       * @see org.apache.cocoon.generation.Generator#generate()
      public void generate() throws SAXException
                  HttpRequest request = (HttpRequest)

                  InputStream in = request.getInputStream();
                  InputSource inSrc = new InputSource(in);

                  XMLReader reader = XMLReaderFactory.createXMLReader();

            catch (IOException e)
                  throw new SAXException(e);

This would be an easy approach without storing the XML on the server.
Using the WriteSourceTransformer inside your pipeline could save the
"uploaded" xml on disk if you want to.

good luck!

Manfred am 10.10.2003 15:22:46

Bitte antworten an

Thema:   Greetings and question

Hello all,

I subscribed to this list awhile back, when I was evaluating Cocoon 2.0. In
time I had to put it
aside. Now I'm returning to it, as I hope it may be the right tool for a
couple of of projects I
have underway.

My background: I manage web operations for a central bank. I'm not
primarily a developer,
though I know the basics of the environments that Cocoon runs in. (e.g., I
have a general
grasp of Java, Tomcat, XML/XSLT, etc.)  However, there are numerous large
gaps in my
knowledge. So please bear with me if some of my questions are kind of
simple-minded :)

Now for my first question. I have a requirement to create an 'interactive'
transformer. This would entail a web form to which a user could upload an
XML file from his
local drive, pass it to an XSLT transformer, and view the generated HTML
file. See this URL
for a related page I have running:

So I want something similar to this page, except that users could upload
their own XML files,
rather then merely select pre-existing ones from a list. The XSLT file
would be 'hard coded'

It seems to me this should be fairly simple to do in Cocoon 2.1.1 Does
anyone have some
existing code samples they could point me to here?

I'm running Cocoon 2.2.1 under JDK 1.4, Tomcat, and Linux.

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

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

View raw message