Introducing Apache Cocoon

Introducing Apache Cocoon

<CocoonDay="2003-Nov-18" /> 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 PERL 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 Java 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 pipeline 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 <?xmlversion="1.0"?> <document> <title>Hello</title> <text>This is my first Cocoon page!</text> </document> 24.11.2003 14 Open Source Introducing Apache Cocoon Putting Cocoon to work Layout: The XSLT Stylesheet File <?xmlversion="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="document"> <html> <body> <h1><xsl:value-of select="title"/></h1> <p><xsl:value-of select="text"/></p> </body> </html> </xsl:template> </xsl:stylesheet> 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 <map:sitemap> Contains set of ready-to-use components <map:components> Use them to build functions <map:generators/> <map:transformers/> Write and „drop-in“ your own <map:serializers/> <map:readers/> Contains collection of Pipelines (Functions) <map:selectors/> <map:matchers/> <map:actions/> <map:pipes/> </map:components> <...> <map:pipelines> <map:pipeline/> <map:pipeline/> <...> </map:pipelines> </map:sitemap> 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 <map:generate type="file" src="helloworld.xml"/> <map:transform type="xslt" src="helloworld2html.xsl"/> <map:serialize type="html"/> 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 <map:match pattern="helloworld" type="wildcard"> <map:generate type="file" src="helloworld.xml"/> <map:transform type="xslt" src="helloworld2html.xsl"/> <map:serialize type="html"/> </map:match> 24.11.2003 22 Open Source Introducing Apache Cocoon Sitemap defaultdefault compocomponnentent <map:sitemap xmlns="http://xml.apache.org/cocoon/sitemap/1.0"> <map:components> <map:generators default="file"> <map:generate name="file" src="org.apache.cocoon.generation.FileGenerator"/> </map:generators> <map:transformers default="xslt"> <map:transformer name="xsltnamename" src="org.apache.cocoon.transformation.TraxTransformersrcsrc "/> </map:transformers> <map:serializers default="html"> <map:serializer name="html" src="org.apache.cocoon.serialization.HTMLSerializer" mime-type="text/html"/> </map:serializers> <map:matchers default="wildcard"> <map:matcher name="wildcard" src="org.apache.cocoon.matching.WildcardURIMatcherFactory"/> </map:matchers> <map:pipes/> defaultdefault ccoomponentmponent </map:components> <map:pipelines> usedused <map:pipeline> <map:match pattern="helloworld"> <map:generate src="helloworld.xml"/> <map:transform src="helloworld2html.xsl" type="xslt"/> <map:serialize/> </map:match> </map:pipeline> explicit </map:pipelines> explicit </map:sitemap> 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 <result> <result> <name>Matthew</name> <name>Matthew</name> <address> <address> <select from database> Paderborn, Germany </address> Database </address> </result> </result> 24.11.2003 24 Open Source Introducing Apache Cocoon Matching a request Matcher Matches the incoming request to the correct pipeline Different types of matchers available Most common: wildcard <map:match pattern="news/*" type="wildcard"> <map:generate src="newsfeeds/{1}.xml" type="file"/> <map:transform src="news2html.xsl" type="xslt"/> <map:serialize type="html"/> </map:match> <map:match pattern="products/*" type="wildcard"> <map:generate src="products/infos/product_{1}.xml" type="file"/> <map:transform src="products2html.xsl" type="xslt"/> <map:serialize type="html"/> </map:match> 24.11.2003 25 Open Source Introducing Apache Cocoon Cocoon Basics Using Cocoon Program the Sitemap Define the matches and pipelines Separating Content from Layout Generator Transformer Transforme r Transforme r Serializer File / HTTP / FTP XSLT Transformer HTML Serializer Generator (Xalan, XSLTC, Saxon...) WML Serializer Directory Generator Data Transformer XML Serializer System Info Generators (SQL, LDAP, Session...) PDF/PS/RTF Serializer Scripting Generators Aggregation Transformers Office Documents (XSP, Velocity, Jexl ...) Filter Transformers Serializer Custom Custom Custom 24.11.2003 26 Open Source Introducing Apache Cocoon Beyond The Basics 24.11.2003 27 Open Source Introducing Apache Cocoon Additional components Selectors Areusedtodetermine the"flow"throughapipeline They are like"if-else-if"statementsinprogramming languages Example: BrowserSelector Can detect used browser Select stylesheetsdependentonthe browser Other

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    46 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us