cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Torsten Curdt" <tcu...@dff.st>
Subject XSPGenerator (ricardo?)
Date Tue, 12 Dec 2000 10:22:19 GMT
I've some questions regarding the XSPGenerator class.

I'm trying to call a generate methode from another
XSPGenerator.

class _index_xml extends XSPGenerator{
    public void generate() throws SAXException {
    /* some SAX */

    /* create an instance of _include_xml */
    /* later on include.xml should appear in the */
    /* dependencies */
    _included_xml g = new _included_xml();

    /* copy the needed attributes */
    g.setContentHandler(this.contentHandler);
    g.setLexicalHandler(this.lexicalHandler);

    /* direct output from the other XSPGenerator */
    /* in the same pipeline */
    g.generate();

    /* some SAX */
    }
}

class _included_xml extends XSPGenerator{
    public void generate() throws SAXException {
    /* some SAX */
    }
}

1. Do I need to do a full copy of all attributes?
   (if then - what about implementing cloneable?)
   Which are required for the generate to work
   properly?

   protected javax.servlet.http.HttpServletRequest request
   protected javax.servlet.http.HttpServletResponse response
   protected javax.servlet.ServletContext context
   protected org.apache.avalon.ComponentManager manager
   protected org.xml.sax.EntityResolver resolver
   protected java.util.Map objectModel
   protected org.apache.avalon.Parameters parameters
   protected java.lang.String source
   protected org.apache.log.Logger log
   protected org.xml.sax.ContentHandler contentHandler
   protected org.xml.sax.ext.LexicalHandler lexicalHandler

2. Do I need to initialize anything else when creating
   a XSPGenerator this way? (Sorry, to bother you I'm
   still not that into the C2 source code)

3. Calling another generate method would give us another

    this.contentHandler.startDocument();
    this.contentHandler.startPrefixMapping("xsp", "http://apache.org/xsp");
    this.contentHandler.endPrefixMapping("xsp");
    this.contentHandler.endDocument();

   I guess they shouln'd be called since there are
   alreay some in the pipeline, right?

   What about having two methods in XSPGenerator then?

    class _included_xml extends XSPGenerator{
      public void generateContent() throws SAXException {
         /* SAX */
      }

      public void generate() throws SAXException {
         this.contentHandler.startDocument();
         this.contentHandler.startPrefixMapping("xsp",
"http://apache.org/xsp");

         generateContent();

         this.contentHandler.endPrefixMapping("xsp");
         this.contentHandler.endDocument();
      }
    }

If this is done we could extend the xinclude syntax to
e.g. <xinclude:include parse="xml" type="serverpage" href="included.xml"/>
And voila... basic content aggregation
--
Torsten


Mime
View raw message