cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manfred.wei...@rzb.at
Subject Antwort: Greetings and question
Date Fri, 10 Oct 2003 14:10:45 GMT

Hello,

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
output.

e.g.
package xx.yy.zz;

import java.io.IOException;
import java.io.InputStream;

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
Parameterizable
{
      /**
       * @see
org.apache.avalon.framework.parameters.Parameterizable#parameterize(Parameters)
       */
      public void parameterize(Parameters parameters) throws
ParameterException
      {
      }

      /**
       * @see org.apache.cocoon.generation.Generator#generate()
       */
      public void generate() throws SAXException
      {
            try
            {
                  HttpRequest request = (HttpRequest)
ObjectModelHelper.getRequest(objectModel);

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

                  XMLReader reader = XMLReaderFactory.createXMLReader();
                  reader.setContentHandler(contentHandler);

                  reader.parse(inSrc);
            }
            catch (IOException e)
            {
                  e.printStackTrace();
                  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!

regards
Manfred





beades@almonte.com am 10.10.2003 15:22:46

Bitte antworten an users@cocoon.apache.org@inet

An:      users@cocoon.apache.org
Kopie:
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'
XML/XSLT
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:

    http://centralbanks.net/sdmx/sdmx_xsl.html

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'
in.

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 4.1.1.8, and Linux.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org









---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message