Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 9997 invoked from network); 18 Nov 2005 04:22:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Nov 2005 04:22:34 -0000 Received: (qmail 20168 invoked by uid 500); 18 Nov 2005 04:18:02 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 18810 invoked by uid 500); 18 Nov 2005 04:17:12 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 18268 invoked by uid 99); 18 Nov 2005 04:15:52 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 17 Nov 2005 20:15:15 -0800 Received: (qmail 7302 invoked by uid 65534); 18 Nov 2005 04:14:54 -0000 Message-ID: <20051118041454.7298.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r345438 [8/286] - in /cocoon/site/site/2.1: ./ developing/ developing/portal/ developing/portal/coplets/ developing/webapps/ developing/webapps/authentication/ faq/ howto/ installing/ plan/ plan/documentation/ plan/otherplanning/ plan/overv... Date: Fri, 18 Nov 2005 04:13:22 -0000 To: cvs@cocoon.apache.org From: crossley@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: cocoon/site/site/2.1/developing/extending.html URL: http://svn.apache.org/viewcvs/cocoon/site/site/2.1/developing/extending.html?rev=345438&view=auto ============================================================================== --- cocoon/site/site/2.1/developing/extending.html (added) +++ cocoon/site/site/2.1/developing/extending.html Thu Nov 17 20:00:02 2005 @@ -0,0 +1,1468 @@ + + + + + + + +Extending Apache Cocoon + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + +
+
+
+
+ +
+ + +
+ +
+ +   +
+ + + + + +
+

Extending Apache Cocoon

+ +

Introduction

+
+

If you want to extend the functionality of Apache Cocoon, it may be unclear +how to achieve your goal. This page tries to indicate when to write what, and to +give an overview of what already exists (so you don't duplicate other's +efforts).

+
+ +

When to write a Generator

+
+

From the sitemap documentation: "A Generator generates XML content +as SAX events and initializes the pipeline processing. "

+

Thus a Generator is the starting point of a pipeline: it produces +the first SAX events on which all other components of the pipeline are +triggered.

+

You may want to write a Generator if you want some other basis for +your SAX events (maybe you want a SAX event every time the temperature of your +CPU changes?) However, before writing a Generator from scratch, it may +be worthwhile to have a look at XSP, which can create a +Generator for you.

+

Existing Generators are:

+
    + +
  • +DirectoryGenerator - Generates an XML directory listing.
  • + +
  • +FileGenerator - Does the job of an XML parser: read an XML file and +outputs SAX events.
  • + +
  • +HTMLGenerator - Takes an HTML URL, makes an XHTML of it, and +outputs the SAX events caused by this XHTML.
  • + +
  • +ImageDirectoryGenerator - An extension of DirectoryGenerators that +adds extra attributes for image files.
  • + +
  • +PhpGenerator - Allows PHP to be used as a generator. Builds upon +the PHP servlet functionality. Overrides the output method in order to pipe the +results into SAX events.
  • + +
  • +RequestGenerator - [FIXME: This looks like just outputing the +request headers, the request parameters and the configuration parameters. But I +don't see any use of it (besides debugging and demonstration). Are there other +situations in which you might want to use this?]
  • + +
  • +ServerPagesGenerator - Makes a Generator at compile time, +based on the src file you define in the sitemap. This one is +responsible for making your XSP pages work.
  • + +
  • +StatusGenerator - Generates an XML representation of the current +status of Cocoon. This can be considered "for administration use", i.e. your +application probably won't deal with this one.
  • + +
+

All these classes are in the org.apache.cocoon.generation package. +In the same package, you find following helper classes and interfaces:

+
    + +
  • +Generator - The interface you have to implement if you want to +write a Generator.
  • + +
  • +AbstractGenerator - Extend this one for easier building of your own +Generator.
  • + +
  • +AbstractServerPage - [FIXME: This seems to be intended as basis for +the ServerPagesGenerator, but it seems to be obsolete now?]
  • + +
  • +ComposerGenerator - Can be used as base class if you want your +Generator to be an Avalon Composable.
  • + +
  • +ServletGenerator - If you want to generate servlets. This is the +base class for the ServerPagesGenerator.
  • + +
+
+ +

When to write a Transformer

+
+

Let's start again from the sitemap documentation: "A Transformer +transforms SAX events in SAX events." In other words, a Transformer +outputs SAX events based on SAX events it receives.

+

You can imagine a Transformer doing many things, from XSLT +processing over database querying to sending mail (and much further, of course). +

+

These Transformers are standard available:

+
    + +
  • +LogTransformer - This is a class that can be plugged into a +pipeline to print the SAX events which passes through this Transformer +in a readable form to a file. This Transformer's main purpose is +debugging.
  • + +
  • +SQLTransformer - Can be used for querying a SQL database.
  • + +
  • +XalanTransformer - Probably the most intuitive +Transformer: it applies an XSL sheet to the SAX events it receives. It +uses Xalan in the process.
  • + +
  • +XIncludeTransformer - To include other XML documents in your "XML +document" (which at transformation time exists in SAX events).
  • + +
  • +XTTransformer - The same as XalanTransformer, but this one +uses XT.
  • + +
+

All these classes can be found in org.apache.cocoon.transformation, +along with these helper classes and interfaces:

+
    + +
  • +Transformer - The interface each Transformer has to implement.
  • + +
  • +AbstractTransformer - A helper base class for implementing a +Transformer.
  • + +
  • +AbstractDOMTransformer - An Abstract DOM Transformer (helper base +class), for use when a transformer needs a DOM-based view of the document.
  • + +
+
+ +

When to write a Serializer

+
+

No need for re-inventing the wheel, so let's start again with the sitemap +documentation: "A Serializer transforms SAX events in binary or char +streams for final client consumption." A Serializer is always the last +step in a pipeline, and gives the client its final result: an HTML page, a nice +PNG picture, a sound stream, or maybe just an XML document.

+

You should write a Serializer if you want to serve a client with +some format that hasn't been provided yet.

+

Existing Serializers:

+
    + +
  • +FOPSerializer- Make PDF files.
  • + +
  • +HTMLSerializer - Generate an HTML document.
  • + +
  • +LinkSerializer- Show the targets of the links in the document.
  • + +
  • +SVGSerializer- To construct an SVG.
  • + +
  • +TextSerializer - Generate a text document.
  • + +
  • +XMLSerializer - Generate an XML document.
  • + +
+

Again, these can be found in the package +org.apache.cocoon.serialization. And this package also includes +following interfaces and helper classes:

+
    + +
  • +Serializer - The interface every Serializer has to +implement.
  • + +
  • +AbstractTextSerializer - Use this as base for your +Serializer if you want to output a character stream.
  • + +
  • +AbstractSerializer - A more general base class.
  • + +
+
+ +

About Action

+
+

[FIXME: We have to wait until we can see what is going to happen here. Also, +I wonder if this belongs here or should deserve a separate page.]

+

The Action part will be used for making Cocoon able to react on form input. +This will make Cocoon no longer a simple basis for web publishing, but will make +it apt for web interaction as well.

+

See Actions.

+
+ +

About XSP

+
+

XSP stands for "eXtensible Server Pages". It is the idea to program +Generators by means of XML. The basic idea is to put XML tags like +<xsp:logic> in your XML file, with in those tags Java code.

+
+
Note
+
This is not the proper way to use XSP's. I just mentioned them +here so you wouldn't forget their existence. Look to the +XSP page for more information.
+
+ +
+
+ +
 
+
+ + + Propchange: cocoon/site/site/2.1/developing/extending.html ------------------------------------------------------------------------------ svn:eol-style = native