Hi
Here is a dummy generator that parses a string and gives the sax events to 
cocoon. Hope that is what you need.
 From my experience I can tell that it is not the best thing to do with 
cocoon2...
Regards

Alex



import  org.apache.avalon.framework.parameters.Parameters;
import  org.apache.cocoon.generation.Generator;
import  org.apache.cocoon.environment.SourceResolver;
import  org.apache.cocoon.xml.XMLConsumer;
import  org.apache.cocoon.ProcessingException;

import  org.xml.sax.XMLReader;
import  org.xml.sax.InputSource;
import  org.xml.sax.SAXException;

import  java.io.StringReader;
import  java.io.IOException;
import  java.util.Map;
import  java.util.Enumeration;



/**
 * A dummy generator for cocoon2
 */
public class DummyGenerator implements Generator {


    protected XMLConsumer   _xmlConsumer;

    public DummyGenerator() {
    }



    public void generate() throws IOException, SAXException, ProcessingException {

        try {
            XMLReader parser = 
(XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance();
            parser.setContentHandler(_xmlConsumer);

            parser.setFeature( "http://xml.org/sax/features/validation",false);

            parser.parse(
                new InputSource(
                    new StringReader(
                        "<page><title>Hello !</title><content><para>This is the result 
of a dummy producer!</para></content></page>")
                            )
                        );
        } catch ( Exception e ) {
            throw new ProcessingException(e);
        }
    }
    public void setConsumer(XMLConsumer consumer) {
        _xmlConsumer = consumer;
    }
    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters 
par)
                                        throws ProcessingException, SAXException, 
IOException {

        System.out.println("setup method");


    }
}

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

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

Reply via email to