cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Istvan Beszteri <>
Subject own generator
Date Wed, 31 Jul 2002 17:36:25 GMT
Hi All,

I'd like to write my own generator. I have written the following generator 
according to the documents on the Cocoon 2 site, by extending an example.
I can start the generator properly, but I can not pass any parameter to it.
Somehow I'd like to reach the HTTP request itself (requested URI, headers 
etc.) within the generator.

public class AnyName extends AbstractGenerator
     * The only implemented method from AbstarctGenerator.
     * It simply generates SAX events from a string.

    public void generate() throws IOException, SAXException, 
	//This string will be feeded to the transformer pipeline as sax events
        String xmlText = "<doc>\nMy first Cocoon 2 generator\n";

	//This object will read and parse the XML content
        XMLReader xmlReader = XMLReaderFactory.createXMLReader();

	//super.xmlConsumer will receive the SAX events
        String paramNames[] = parameters.getNames();

        xmlText += "Number of parameters: " + paramNames.length + "\n";

	xmlText += "Parameter names:\n";

        for(int i = 0; i < paramNames.length; i++)
            xmlText += paramNames[i] + "\n";

        xmlText += "Source: " + source + "\n";

	xmlText += "</doc>";

        //Create an InputSource from the hardcoded string
        InputSource src = new InputSource(new StringReader(xmlText));

	//Parse the XML input and generate SAX events to the consumer

I use the following pipeline. In the generated XML I could see the 
parameters, and the source, but it seems that the source is null, and no 
parameters are passed to the generator.

    <map:match pattern="foo/*">
      <map:act type="request">
        <map:parameter name="parameters" value="true"/>
        <map:generate type="ist" source="{1}"/>
        <map:serialize type="xml"/>

      <map:transform src="stylesheets/system/error2html.xsl"/>
      <map:serialize status-code="500"/>

How could I get the request data in the generator?

Thanks in advance!

Please check that your question  has not already been answered in the
FAQ before posting.     <>

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

View raw message