home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / extending.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  8.9 KB  |  194 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "document-v10.dtd">
  18.  
  19. <document>
  20.     <header>
  21.         <title>Extending Apache Cocoon</title>
  22.         <version>0.1</version>
  23.         <type>Technical document</type>
  24.         <authors>
  25.             <person name="Tom Klaasen" email="tom.klaasen@pandora.be"/>
  26.         </authors>
  27.     </header>
  28.     <body>
  29.         <s1 title="Introduction">
  30.             <p>If you want to extend the functionality of Apache Cocoon, it may be unclear
  31.           how to achieve your goal. This page tries to indicate when to write what, and
  32.           to give an overview of what already exists (so you don't duplicate other's
  33.           efforts).</p>
  34.         </s1>
  35.         <s1 title="When to write a Generator">
  36.             <p>From the sitemap documentation: "A <code>Generator</code> generates
  37.           XML content as SAX events and initializes the pipeline processing. "</p>
  38.             <p>Thus a <code>Generator</code> is the starting point of a pipeline: it
  39.           produces the first SAX events on which all other components of the pipeline are
  40.           triggered.</p>
  41.             <p>You may want to write a <code>Generator</code> if you want some other
  42.           basis for your SAX events (maybe you want a SAX event every time the
  43.           temperature of your CPU changes?) However, before writing a
  44.           <code>Generator</code> from scratch, it may be worthwhile to have a look at
  45.           <link href="#xsp">XSP</link>, which can create a <code>Generator</code> for
  46.         you.</p>
  47.             <p>Existing <code>Generator</code>s are: </p>
  48.             <ul>
  49.                 <li>
  50.                     <code>DirectoryGenerator</code> - Generates an XML directory
  51.              listing.</li>
  52.                 <li>
  53.                     <code>FileGenerator</code> - Does the job of an XML parser: read an
  54.              XML file and outputs SAX events.</li>
  55.                 <li>
  56.                     <code>HTMLGenerator</code> - Takes an HTML URL, makes an XHTML of
  57.              it, and outputs the SAX events caused by this XHTML.</li>
  58.                 <li>
  59.                     <code>ImageDirectoryGenerator</code> - An extension of
  60.              DirectoryGenerators that adds extra attributes for image files. </li>
  61.                 <li>
  62.                     <code>PhpGenerator</code> - Allows PHP to be used as a generator.
  63.              Builds upon the PHP servlet functionality. Overrides the output method in
  64.              order to pipe the results into SAX events.</li>
  65.                 <li>
  66.                     <code>RequestGenerator</code> - [FIXME: This looks like just
  67.              outputing the request headers, the request parameters and the configuration
  68.              parameters. But I don't see any use of it (besides debugging and
  69.              demonstration). Are there other situations in which you might want to use
  70.              this?]</li>
  71.                 <li>
  72.                     <code>ServerPagesGenerator</code> - Makes a <code>Generator</code>
  73.              at compile time, based on the <code>src</code> file you define in the sitemap.
  74.              This one is responsible for making your XSP pages work.</li>
  75.                 <li>
  76.                     <code>StatusGenerator</code> - Generates an XML representation of
  77.              the current status of Cocoon. This can be considered "for administration use",
  78.              i.e. your application probably won't deal with this one.</li>
  79.             </ul>
  80.             <p>All these classes are in the <code>org.apache.cocoon.generation</code>
  81.           package. In the same package, you find following helper classes and
  82.           interfaces:</p>
  83.             <ul>
  84.                 <li>
  85.                     <code>Generator</code> - The interface you have to implement if you
  86.              want to write a <code>Generator</code>.</li>
  87.                 <li>
  88.                     <code>AbstractGenerator</code> - Extend this one for easier
  89.              building of your own <code>Generator</code>.</li>
  90.                 <li>
  91.                     <code>AbstractServerPage</code> - [FIXME: This seems to be intended
  92.              as basis for the <code>ServerPagesGenerator</code>, but it seems to be obsolete
  93.              now?]</li>
  94.                 <li>
  95.                     <code>ComposerGenerator</code> - Can be used as base class if you
  96.              want your <code>Generator</code> to be an <link href="avalon.html">Avalon
  97.         Composable</link>.</li>
  98.                 <li>
  99.                     <code>ServletGenerator</code> - If you want to generate servlets.
  100.           This is the base class for the <code>ServerPagesGenerator</code>.</li>
  101.             </ul>
  102.         </s1>
  103.         <s1 title="When to write a Transformer">
  104.             <p>Let's start again from the sitemap documentation: "A
  105.           <code>Transformer</code> transforms SAX events in SAX events." In other words,
  106.           a <code>Transformer</code> outputs SAX events based on SAX events it
  107.           receives.</p>
  108.             <p>You can imagine a <code>Transformer</code> doing many things, from
  109.           XSLT processing over database querying to sending mail (and much further, of
  110.           course).</p>
  111.             <p>These <code>Transformer</code>s are standard available:</p>
  112.             <ul>
  113.                 <li>
  114.                     <code>LogTransformer</code> - This is a class that can be plugged
  115.              into a pipeline to print the SAX events which passes through this
  116.              <code>Transformer</code> in a readable form to a file. This
  117.              <code>Transformer</code>'s main purpose is debugging.</li>
  118.                 <li>
  119.                     <code>SQLTransformer</code> - Can be used for querying a SQL
  120.              database.</li>
  121.                 <li>
  122.                     <code>XalanTransformer</code> - Probably the most intuitive
  123.              <code>Transformer</code>: it applies an XSL sheet to the SAX events it
  124.              receives. It uses Xalan in the process.</li>
  125.                 <li>
  126.                     <code>XIncludeTransformer</code> - To include other XML documents
  127.              in your "XML document" (which at transformation time exists in SAX
  128.              events).</li>
  129.                 <li>
  130.                     <code>XTTransformer</code> - The same as
  131.              <code>XalanTransformer</code>, but this one uses XT.</li>
  132.             </ul>
  133.             <p>All these classes can be found in
  134.           <code>org.apache.cocoon.transformation</code>, along with these helper classes
  135.           and interfaces:</p>
  136.             <ul>
  137.                 <li>
  138.                     <code>Transformer</code> - The interface each Transformer has to
  139.              implement.</li>
  140.                 <li>
  141.                     <code>AbstractTransformer</code> - A helper base class for
  142.              implementing a <code>Transformer</code>.</li>
  143.                 <li>
  144.                     <code>AbstractDOMTransformer</code> - An Abstract DOM Transformer
  145.              (helper base class), for use when a transformer needs a DOM-based view of the
  146.              document.</li>
  147.             </ul>
  148.         </s1>
  149.         <s1 title="When to write a Serializer">
  150.             <p>No need for re-inventing the wheel, so let's start again with the
  151.           sitemap documentation: "A <code>Serializer</code> transforms SAX events in
  152.           binary or char streams for final client consumption." A <code>Serializer</code>
  153.           is always the last step in a pipeline, and gives the client its final result:
  154.           an HTML page, a nice PNG picture, a sound stream, or maybe just an XML
  155.           document.</p>
  156.             <p>You should write a <code>Serializer</code> if you want to serve a  client with some format that hasn't been provided yet.</p>
  157.             <p>Existing <code>Serializer</code>s:</p>
  158.             <ul>
  159.                 <li>
  160.                     <code>FOPSerializer</code>- Make PDF files.</li>
  161.                 <li>
  162.                     <code>HTMLSerializer</code> - Generate an HTML document.</li>
  163.                 <li>
  164.                     <code>LinkSerializer</code>- Show the targets of the links in the document.</li>
  165.                 <li>
  166.                     <code>SVGSerializer</code>- To construct an SVG.</li>
  167.                 <li>
  168.                     <code>TextSerializer</code> - Generate a text document.</li>
  169.                 <li>
  170.                     <code>XMLSerializer</code> - Generate an XML document.</li>
  171.             </ul>
  172.             <p>Again, these can be found in the package <code>org.apache.cocoon.serialization</code>. And this package also includes following interfaces and helper classes:</p>
  173.             <ul>
  174.                 <li>
  175.                     <code>Serializer</code> - The interface every <code>Serializer</code> has to implement.</li>
  176.                 <li>
  177.                     <code>AbstractTextSerializer</code> - Use this as base for your <code>Serializer</code> if you want to output a character stream.</li>
  178.                 <li>
  179.                     <code>AbstractSerializer</code> - A more general base class.</li>
  180.             </ul>
  181.         </s1>
  182.         <s1 title="About Action">
  183.             <p>[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.]</p>
  184.             <p>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.</p>
  185.             <p>See <link href="../userdocs/concepts/actions.html">Actions</link>.</p>
  186.         </s1>
  187.         <s1 title="About XSP">
  188.             <anchor id="xsp"/>
  189.             <p>XSP stands for "eXtensible Server Pages". It is the idea to program <code>Generator</code>s by means of XML. The basic idea is to put XML tags like <code><![CDATA[<xsp:logic>]]></code> in your XML file, with in those tags Java code.</p>
  190.             <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 <link href="../userdocs/xsp/xsp.html">XSP page</link> for more information.</note>
  191.         </s1>
  192.     </body>
  193. </document>
  194.