|
|
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 Generator s 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
Composer.
-
ServletGenerator - If you want to generate servlets.
This is the base class for the ServerPagesGenerator .
|
[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.
|
XSP stands for "eXtensible Server Pages". It is the idea to program Generator s 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.
 | 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. |
|
|
|