Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Publish dynamic XML content with Cocoon 2, Part 1: Introduction to Cocoon 2

An open-source XML/XSLT publishing framework

Leigh Dodds (leigh@xmlhack.com), Developer and editor, Ingenta, Ltd.
Photo of Leigh Dodds
Leigh Dodds is team leader of the Research and Technology Group at Ingenta, Ltd. He has five years of experience in developing on the Java platform, and he has spent the last three years working with XML and related technologies. Leigh is also a contributing editor to xmlhack.com, and has been writing the regular "XML-Deviant" column on XML.com since February 2000. He holds a bachelor's degree in biological science, and a master's in computing. When he's not wrestling with pointy brackets, Leigh can be found making silly noises with his son, Ethan.

Summary:  Whereas EDI for years has provided a usable but expensive way for companies to exchange information in an automated manner, ebXML now provides a means for companies to integrate their processes much more easily. Based on XML, it provides a methodology for business to determine what information they should exchange and how, as well as a set of specifications to allow automation of the process. This tutorial gives an overview of ebXML, explaining how all of the pieces fit together.

View more content in this series

Date:  12 Mar 2002
Level:  Introductory PDF:  A4 and Letter (74 KB | 21 pages)Get Adobe® Reader®

Activity:  6887 views
Comments:  

Tutorial introduction

What is Cocoon?

Cocoon is a Java server framework that allows the dynamic publishing of XML content using XSLT (XML Stylesheet Language-Transformation) transformations. By relying on XML to describe content, and XSLT as a means of transforming that content into multiple formats, Cocoon provides a platform for building applications with strong separation between content, logic, and presentation.

Cocoon uses the concept of a pipeline to describe the process of publishing content to the Web. A wide variety of reusable components are included, which can be configured to produce complex behavior with a minimum of Java development. For example, using XML and XSLT alone, Cocoon can be used to:

  • Serve static files as well as dynamically generated responses
  • Map user requests transparently onto physical resources with an arbitrary amount of processing
  • Perform both simple and multistage XSLT transformations
  • Pass parameters dynamically to XSLT transformations
  • Generate a wide variety of output formats including XML, HTML, PNG, JPEG, SVG, and PDF

This all adds up to a great deal of power that can be put to work using existing skills in XML and XSLT. Cocoon lets you produce dynamic Web sites with a minimum of fuss.


Cocoon 1 and Cocoon 2

Cocoon is an open-source project being developed as part of the Apache XML effort. Cocoon 2 is a complete rewrite of the original Cocoon application and is the recommended version. New users should start directly with Cocoon 2, while existing Cocoon 1 users are encouraged to upgrade.

The aim of the Cocoon 2 project was to take the lessons learned during Cocoon 1 development and use them to engineer a more efficient and scalable platform. In particular, Cocoon 1 relied on the Document Object Model (DOM) API to pass XML data between components. The DOM is an inefficient means of passing data because a typical DOM tree can consume several times more memory than the original XML document. This severely limited Cocoon's scalability. Cocoon 2 is built around the SAX API, which is a more lightweight means of manipulating XML data.

Another key difference between the two versions of Cocoon centers on application management. In Cocoon 1, individual XML documents declared how they should be processed by including Cocoon processing instructions. This tied documents to specific processing, greatly restricting flexibility to reuse content in different ways. Cocoon 2 factors out management of processing into a configuration file known as a sitemap. This separates out the processing logic from the content itself, which in turn separates concerns among content, logic, and presentation.

Cocoon 2, because it is a more scalable and flexible platform than the original Cocoon application, is the focus of this tutorial.


Who should take this tutorial?

To get the most from this tutorial, and Cocoon 2, readers should already be familiar with XML and XSLT. While Cocoon is a Java application, you don't need any in-depth Java experience to use it.

This tutorial covers the following:

  • How to install and configure Cocoon
  • An introduction to the principles of the Cocoon 2 architecture and its key components
  • An introduction to the sitemap -- the means of managing Cocoon Web applications
  • Example pipeline configurations that demonstrate how to construct a dynamic Web site using Cocoon and XSLT

Tools

Cocoon is a Java Web application and must be run within a Java-Servlet-2.2-compliant servlet engine. The next section, Installing and configuring Cocoon , includes details on how to download and install Jakarta Tomcat 4.0.1, the latest reference implementation of the servlet API.

Both Tomcat and Cocoon require installation of a Java 2 development kit. The Java 2 SDK, 1.3.1 can be downloaded from http://java.sun.com/j2se/.

To fetch the Cocoon source code so the application can be built locally, CVS also needs to be installed. See the CVS Web site, http://www.cvshome.org/, for further information.

1 of 8 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML
ArticleID=138133
TutorialTitle=Publish dynamic XML content with Cocoon 2, Part 1: Introduction to Cocoon 2
publish-date=03122002
author1-email=leigh@xmlhack.com
author1-email-cc=dwxed@us.ibm.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.