<<

Introducing Apache Cocoon

Matthew Langham

Leiter CompetenceCenter OpenSource S&N AG Open Source Introducing Apache Cocoon

The Project

Origins Started by Stefano Mazzocchi Redesign of Apache.org Frustrated by the limitations of HTML Wanted to use emerging technologies (XML/XSL) Today Now one of the most important Apache projects Incorporates technologies from various projects Large community Large commercial adoption Open Source

24.11.2003 2 Open Source Introducing Apache Cocoon

Timeline 1979 Sendmail –Eric Allmann Open Source 1983 GNU –RIchardStallmann 1986 1991Linux 1994 Red Hatfounded 1995 Apache Web Server “Open Source” coined in 1998 1998 Netscape Mozilla Netscape releases source code 1998 „Open Source“ “Free software” has been around since at least the 1980’s Today “Open Source” is used liberally Different licences Different availability of source and binaries Licences Main aspect when using commercially At least 30 different licences Cocoon is released under the Apache Software Licence

24.11.2003 3 Open Source Introducing Apache Cocoon

What is Cocoon?

In A Nutshell Extensible framework for XML based publishing Uses XSLT for multi-channel publishing Allows the integration of various data-sources using provided components Allows processing, aggregation of data Additional components provide portal, authentication, forms, flow.. Drop in new components to extend functionality Usage scenarios Web Sites Publishing of Data (Web Printing) Portals XML Processing architectures Just about anything really….

24.11.2003 4 Open Source Introducing Apache Cocoon

Why is Cocoon different?

Completely based on XML Separation of Concerns (SoC) Site Administrator Content Deployer Layout Deployer Provides for many (all?) aspects of today's Web applications Publishing, Aggregation Portals, Form handling Extensibility Protects your investment Healthy Community

24.11.2003 5 Open Source Introducing Apache Cocoon

Why is Cocoon different?

Document generation on the server Logical names used „http://myserver/cocoon/helloworld“ Powerful Process Description Caching for performance Flexible Data Integration / Aggregation XML files, XML over HTTP Databases, LDAP, SAP … Flexible Publishing to different formats using XSLT HTML, WML, XML PDF, SVG, PS, Office Documents …

24.11.2003 6 Open Source Introducing Apache Cocoon

Installation

What do you need A computer J Java JDK An Internet connection Or some way of getting the distribution Download the distribution from an Apache mirror Includes Jetty as a servlet engine $> ./build.sh $> ./cocoon.shservlet Enjoy

24.11.2003 7 Open Source Introducing Apache Cocoon

24.11.2003 8 Open Source Introducing Apache Cocoon

Finished!

Well....ok.....not quite....

24.11.2003 9 Open Source Introducing Apache Cocoon

NetNet The Big Picture

Listens for incoming requests R R

e (typically on Port 80) e q q u u e e s s t / t R Web Server /

R Web Server e e s p s p o o n n s e s

e Communication channel (type varies depending on Vendor)

SerServletvlet Engine Engine maps Request to a Servlet ServletEngine NetNet maps Request to a Servlet ServletEngine ConConfigufiguratrationion Servlet API Servlet API Canalso listen for incoming requests

(e.g. Tomcat on Port 8080) C O C o O t o c h t o c h e o o e r o n r S n - S e S - e r S e v r e r l v e v r l e l v t e s l t e t s t

24.11.2003 10 Open Source Introducing Apache Cocoon

Documentation Generation

Dynamic Document Generation Based on Request-Response-Cycle (when run as a Servlet) Other Environments possible By defining a processing per document Getting Content Adding Layout Sending Response Extensible by Logic

24.11.2003 11 Open Source Introducing Apache Cocoon

Separating Content and Layout

Layout (XSLT) Document (HTML) apply Content (XML)

apply Document (PDF) Layout (XSLT)

24.11.2003 12 Open Source Introducing Apache Cocoon

Putting Cocoon to work

Hello World example Content: a simple static XML file Layout: an XSLT Stylesheet generating HTML

24.11.2003 13 Open Source Introducing Apache Cocoon

Putting Cocoon to work

Content: Hello World XML File

Hello This is my first Cocoon page!

24.11.2003 14 Open Source Introducing Apache Cocoon

Putting Cocoon to work

Layout: The XSLT Stylesheet File

24.11.2003 15 Open Source Introducing Apache Cocoon

24.11.2003 16 Open Source Introducing Apache Cocoon

Building a Pipeline

Content Layout Document (XML) (XSLT) (HTML)

Generator Transformer Serializer

24.11.2003 17 Open Source Introducing Apache Cocoon

CoCoccoonoon (Servlet)(Servlet) Processing SitemapSitemap Request

Request Generator Transformer Serializer

Response Content Layout (HTML) (XML) (XSLT)

24.11.2003 18 Open Source Introducing Apache Cocoon

Separating Content and Layout

Retrieve Content Layout Serialize Content Request

File Generator HTML Serialize Stylesheet HTML

File Generator WML Serialize Stylesheet WML

File SQL Gener- Trans- HTML Serialize ator former Stylesheet HTML

24.11.2003 19 Open Source Introducing Apache Cocoon

Cocoon Basics

Sitemap Centralized Configuration File in XML Sub-sitemaps possible Contains set of ready-to-use components Use them to build functions Write and „drop-in“ your own Contains collection of Pipelines (Functions) <...> <...>

24.11.2003 20 Open Source Introducing Apache Cocoon

Defining a Pipeline

Sitemap is an XML document Describes the processing steps for a request Defines the pipeline One Generator 0-n Transformer One Serializer

24.11.2003 21 Open Source Introducing Apache Cocoon

Defining a Pipeline

Sitemap is an XML document Describes the processing steps for a request Matches a pipeline to a request URI

http://localhost:8888/helloworld

24.11.2003 22 Open Source Introducing Apache Cocoon

Sitemap defaultdefault compocomponnentent

defaultdefault ccoomponentmponent usedused explicit explicit compocomponnentent usedused 24.11.2003 23 Open Source Introducing Apache Cocoon

Complex Pipeline

Transformer example with commands

Generator SQL Transformer Transformer Serializer

Performs Completed XML Reads Select is passed on XML file

Matthew Matthew