This document is intended for both Users and Developers and presents an overall picture of @Name@.
What You Should know:
What You need not know:
Basic problem to be solved:
Basic mechanisms for processing XML documents:
Sequence of Interactions
Pipeline
An XSP page is an XML page with following requirements:
<xsp:page>
<xsp:page>
element.<xsp:page>
element.<xsp:logic>
and an <xsp:expr>
element.An XSP page is used by a generator to generate XML document.
<xsp:page>
xmlns:... attribute.Sitemap contains configuration information for a Cocoon engine:
Sitemap is an XML file corresponding to a sitemap DTD.
Sitemap can be edited to add new elements.
Sitemap is generated into a program and is compiled into an executable unit.
A Matcher attempts to match an URI with a specified pattern for dispatching the request to a specific processing pipeline.
Different types of matchers:
More matchers can be added without modifying Cocoon.
Matchers help in specifying a specific pipeline processing for a group of URIs.
Sitemap entries for different types of matchers
Pipeline entries in sitemap file
A Generator is used to create an XML structure from an input source (file, directory, stream ...)
Different types of generators:
More generators can be added without modifying Cocoon.
Sitemap entries for different types of generators
A sample generator entries in a pipeline
A Generator turns an XML document, after applying appropriate transformations, into a compiled program whose output is an XML document.
An XSP generator applies all the logicsheets specified in the source XML file before generating the program.
Generators cache the compiled programs for better runtime efficiency.
A Transformer is used to map an input XML structure into another XML structure.
Different types of transformers:
Log Transformer is a good debugging tool.
More transformers can be added without modifying Cocoon.
Sitemap entries for different types of transformers
A sample transformer entry in a pipeline
A Serializer is used to render an input XML structure into some other format (not necessarily XML)
Different types of serializers:
More serializers can be added without modifying Cocoon.
Sitemap entries for different types of serializers
A sample serializer entry in a pipeline
The sitemap configuration allows dynamic setup of processing pipelines consisting of a generator, multiple transformers and a serializer.
Requests are dispatched to a pipeline based on request URI and the pipeline matching pattern (either with wildcards or as a regexp)
The pipeline is setup in the generated file sitemap_xmap.java
(This file gets generated [possibly asynchronously] everytime the sitemap.xmap
is modified.
Logicsheets are XSL files with an associated namespace.
Primary mechanism to add program logic (code) to XSPs.
These need to be registered in configuration file cocoon.xconf.
Logicsheets are used by the generator to transform XML structure before generating program.
Cocoon comes with a no. of built-in logic sheets:
Log.xsl structure
A sample use
Cocoon is highly configurable. Main configuration files, assuming Cocoon deployment as a servlet in a servlet container, are (directory locations assume Tomcat servlet container):
sitemap.xmap
: the sitemap file. By default, located in $TOMCAT_HOME/webapps/cocoon
directory.cocoon.xconf
: configuration file having logicsheet registrations. Specifies, sitemap.xmap location and other such parameters. By default, located in $TOMCAT_HOME/webapps/cocoon
directory.web.xml
: servlet deployment descriptor. Specifies location of cocoon.xconf, log file location and other such parameters. Located in $TOMCAT_HOME/webapps/cocoon/WEB-INF
directory.cocoon.roles
: mapping file for Core Cocoon components name and implementation classes. For example, if you want to use a parser other than the default one, you need to modify this file.Cocoon produces execution log entries for debugging/auditing.
$TOMCAT_HOME/webapps/cocoon/WEB-INF/logs/cocoon.log
.Cocoon keeps the generated .java files in a directory tree
starting at (by default):
$TOMCAT_HOME/webapps/work/localhost_8080%2Fcocoon/org/apache/cocoon/www
.
You can find sitemap_xmap.java here.
Files created by LogTransformer are kept (by default) in $TOMCAT_HOME
directory.
Download Tomcat from Apache site.
Download Cocoon sources from Apache CVS. [Command assume UNIX Bourne shell]
Build sources as per instruction in Install file.
Move the cocoon.war
file to $TOMCAT_HOME/webapps
directory.
Start the servlet engine. Type-in the URL http://localhost:8080/cocoon
in your browser. You should see the Cocoon welcome message.
Consult Install file if you face problems.