Apache Cocoon
Encyclopedia
Apache Cocoon, usually just called Cocoon, is a web application framework
Web application framework
A web application framework is a software framework that is designed to support the development of dynamic websites, web applications and web services. The framework aims to alleviate the overhead associated with common activities performed in Web development...

 built around the concepts of pipeline
Pipeline (software)
In software engineering, a pipeline consists of a chain of processing elements , arranged so that the output of each element is the input of the next. Usually some amount of buffering is provided between consecutive elements...

, separation of concerns
Separation of concerns
In computer science, separation of concerns is the process of separating a computer program into distinct features that overlap in functionality as little as possible. A concern is any piece of interest or focus in a program. Typically, concerns are synonymous with features or behaviors...

 and component-based web development. The framework focuses on XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

 and XSLT
XSLT
XSLT is a declarative, XML-based language used for the transformation of XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one. The new document may be serialized by the processor in standard XML syntax or in another format,...

 publishing and is built using the Java programming language
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

. The flexibility afforded by relying heavily on XML allows rapid content publishing in a variety of formats including HTML
HTML
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....

, PDF, and WML
Wireless Markup Language
Wireless Markup Language , based on XML, is a markup language intended for devices that implement the Wireless Application Protocol specification, such as mobile phones. It provides navigational support, data input, hyperlinks, text and image presentation, and forms, much like HTML...

. The content management system
Content management system
A content management system is a system providing a collection of procedures used to manage work flow in a collaborative environment. These procedures can be manual or computer-based...

s Apache Lenya
Apache Lenya
Apache Lenya is a Java/XML open-source content management system based on the Apache Cocoon content management framework. Features include revision control, scheduling, search capabilities, workflow support, and browser-based WYSIWYG editors....

 and Daisy have been created on top of the framework. Cocoon is also commonly used as a data warehousing ETL
Extract, transform, load
Extract, transform and load is a process in database usage and especially in data warehousing that involves:* Extracting data from outside sources* Transforming it to fit operational needs...

 tool or as middleware
Middleware
Middleware is computer software that connects software components or people and their applications. The software consists of a set of services that allows multiple processes running on one or more machines to interact...

 for transporting data between systems.

Sitemap

The sitemap is at the core of Cocoon. It's here that the web site developer configures the different Cocoon components, and defines the client–server interactions in what Cocoon refers to as the Pipelines
XML pipeline
In software, an XML Pipeline is formed when XML processes, especially XML transformations and XML validations, are connected together....

.

Matchers

Matchers are used to match user requests such as URL
Uniform Resource Locator
In computing, a uniform resource locator or universal resource locator is a specific character string that constitutes a reference to an Internet resource....

s or cookie
HTTP cookie
A cookie, also known as an HTTP cookie, web cookie, or browser cookie, is used for an origin website to send state information to a user's browser and for the browser to return the state information to the origin site...

s against wildcard
Wildcard character
-Telecommunication:In telecommunications, a wildcard character is a character that may be substituted for any of a defined subset of all possible characters....

 or regular expression
Regular expression
In computing, a regular expression provides a concise and flexible means for "matching" strings of text, such as particular characters, words, or patterns of characters. Abbreviations for "regular expression" include "regex" and "regexp"...

 patterns. Each user request is tested against matchers in the sitemap until a match is made. It is within a matcher that the response to a particular request is specified.

Generators

Generators create a stream of data for further processing. This stream can be generated from an existing XML document or there are generators that can create XML from scratch to represent something on the server, such as a directory structure or image data.

XSP

One type of generator is an XML Server Page (XSP http://cocoon.apache.org/1.x/xsp.html), an XML document containing tag-based directives that specify how to generate dynamic content at request time. Upon Cocoon processing, these directives are replaced by generated content so that the resulting, augmented XML document can be subject to further processing (typically an XSLT transformation). XSPs are transformed into Cocoon producers, typically as Java classes, though any scripting language for which a Java-based processor exists could also be used.

Directives can be either built-in ("XSP") or user-defined processing tags, both of which are defined in logicsheets. Tags are defined using XSLT templates that describe how the tags (represented as XML nodes) are transformed into other XML nodes or into procedural code such as Java. The tags are used to embed procedural logic, substitute expressions, retrieve information from the web server environment, and other operations.

Note that XSP is deprecated in recent releases of Cocoon.

Transformers

Transformers take a stream of data and change it in some way. The most common transformations are performed with XSLT to change one xml format into another. But there are also transformers that take other forms of data (SQL
SQL
SQL is a programming language designed for managing data in relational database management systems ....

 commands for example).

Serializers

A serializer turns an XML event stream into a sequence of bytes (such as HTML) that can be returned to the client. There are serializers that allow you to send the data in many different formats including HTML
HTML
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....

, XHTML
XHTML
XHTML is a family of XML markup languages that mirror or extend versions of the widely-used Hypertext Markup Language , the language in which web pages are written....

, PDF
Portable Document Format
Portable Document Format is an open standard for document exchange. This file format, created by Adobe Systems in 1993, is used for representing documents in a manner independent of application software, hardware, and operating systems....

, RTF
Rich Text Format
The Rich Text Format is a proprietary document file format with published specification developed by Microsoft Corporation since 1987 for Microsoft products and for cross-platform document interchange....

, SVG
Scalable Vector Graphics
Scalable Vector Graphics is a family of specifications of an XML-based file format for describing two-dimensional vector graphics, both static and dynamic . The SVG specification is an open standard that has been under development by the World Wide Web Consortium since 1999.SVG images and their...

, WML
Wireless Markup Language
Wireless Markup Language , based on XML, is a markup language intended for devices that implement the Wireless Application Protocol specification, such as mobile phones. It provides navigational support, data input, hyperlinks, text and image presentation, and forms, much like HTML...

 and plain text
Plain text
In computing, plain text is the contents of an ordinary sequential file readable as textual material without much processing, usually opposed to formatted text....

, for example.

Selectors

Selectors offer the same capabilities as a switch statement. They are able to select particular elements of a request and choose the correct pipeline part to use.

Views

Views are mainly used for testing. A view is an exit point in a pipeline. You can put out the XML-Stream which is produced till this point. So you can see if the application is working right.

Actions

Actions are Java classes that execute some business logic or manage new content production.

The Pipeline

A pipeline
XML pipeline
In software, an XML Pipeline is formed when XML processes, especially XML transformations and XML validations, are connected together....

is used to specify how the different Cocoon components interact with a given request
Request
Request may refer to:*a question*in computer science, a message sent between objects*in computer science, a request in Hypertext Transfer Protocol*ReQuest Dance Crew, a hip-hop dance crew from New Zealand*Request TV, a defunct pay-per-view service...

 to produce a response
Response
Response may refer to:*Response , a line answering a versicle*Response or antiphon, a response to a psalm or other part of a religious service* Output or response, the result of telecommunications input...

. A typical pipeline consists of a generator, followed by zero or more transformers, and finally a serializer.

See also

  • Reactor pattern
    Reactor pattern
    The reactor design pattern is an event handling pattern for handling service requests delivered concurrently to a service handler by one or more inputs...

     - the design pattern that Cocoon is based on.
  • XProc
    XProc
    XProc is a W3C Recommendation to define an XML transformation language to define XML Pipelines.Below is an example abbreviated XProc file: This is a pipeline that consists of two atomic steps, XInclude and Validate...

    - a W3C Standard for modelising of XML pipeline.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK