Apache Cocoon 2.0.4

Support

09/Apr/2002 tested by Redhat 8.0

Apache Cocoon is an XML publishing framework that raises the usage of XML and XSLT technologies for server applications to a new level. Designed for performance and scalability around pipelined SAX processing, Cocoon offers a flexible environment based on a separation of concerns between content, logic, and style. To top this all off, Cocoon's centralized configuration system and sophisticated caching help you to create, deploy, and maintain rock-solid XML server applications.

Cocoon interacts with most data sources, including filesystems, RDBMS, LDAP, native XML databases, and network-based data sources. It adapts content delivery to the capabilities of different devices like HTML, WML, PDF, SVG, and RTF, to name just a few. You can run Cocoon as a Servlet as well as through a powerful, commandline interface. The deliberate design of its abstract environment gives you the freedom to extend its functionality to meet your special needs in a highly modular fashion.

Software version

I used following version of softwares in this example.
Software File & Version Source
OS Red Hat 8.0 http://www.redhat.com
Java SDK j2sdk-1_4_1_02-linux-i586-rpm.bin http://java.sun.com/j2se/
Tomcat jakarta-tomcat-4.0.4.tar.gz http://jakarta.apache.org/tomcat/
Cocoon cocoon-2.0.4-vm14-bin.zip http://xml.apache.org/cocoon/

Install Java SDK

  1. Download j2sdk-1_4_1_02-linux-i586-rpm.bin from SUN site (http://java.sun.com/j2se/) and execute it

    # sh ./j2sdk-1_4_1_02-linux-i586-rpm.bin
       Sun Microsystems, Inc.  Binary Code License Agreement
    ...
    Do you agree to the above license terms? [yes or no]
    yes
      inflating: j2sdk-1_4_1_02-fcs-linux-i586.rpm
    Done.

    # rpm -ihv j2sdk-1_4_1_02-fcs-linux-i586.rpm

  2. Edit /etc/bashrc and add following lines

    ...
    export JAVA_HOME="/usr/java/j2sdk1.4.1_02"
    export PATH="$PATH:$JAVA_HOME/bin"
    ...

Install Tomcat binary

  1. Download jakarta-tomcat-4.0.4.tar.gz from Apache Jakarta Project site (http://jakarta.apache.org/tomcat/)
  2. move jakarta-tomcat-4.0.4.tar.gz into /usr/local/ and extract it

    # mv jakarta-tomcat-4.0.4.tar.gz /usr/local
    # tar zxvf jakarta-tomcat-4.0.4.tar.gz

  3. Make a script /etc/rc.d/tc.tomcat to start and stop Tomcat

    #!/bin/sh
    # Tomcat
    # description: Starts and stops the Tomcat
    # See how we were called.

    export JAVA_HOME="/usr/java/j2sdk1.4.1_02"
    export TOMCAT_HOME="/usr/local/jakarta-tomcat-4.0.4"
    export PATH="$PATH:$JAVA_HOME/bin"
    echo

    case "$1" in
      start)
            echo -n "Starting Tomcat services: "
            echo
            $TOMCAT_HOME/bin/startup.sh
            echo
            ;;
      stop)
            echo -n "Shutting down Tomcat services: "
            echo
            $TOMCAT_HOME/bin/shutdown.sh
            echo
            ;;
      status)
            echo | ps ax | grep delegate
            ;;
      restart)
            echo -n "Restarting Tomcat services: "
            $0 stop
            sleep 2
            $0 start
            echo "done."
            ;;
      *)
            echo "Usage: rc.tomcat {start|stop|restart|status}"
            exit 1
    esac

  4. Add the start-up script to /etc/rc.local

    ...
    /etc/rc.d/rc.tomcat start

  5. Start tomcat using the script or reboot. After starting tomcat, you need to wait 10-20 seconds.
  6. Open http://localhost:8080 by browser. You'll see Tomcat default page

Install Cocoon

  1. Download cocoon-2.0.4-vm14-bin.zip from Apache XML Project site (http://xml.apache.org/cocoon/)
  2. Unzip the file

    # unzip cocoon-2.0.4-vm14-bin.zip
    # mv cocoon-2.0.4/cocoon.war /usr/local/jakarta-tomcat-4.0.4/webapp/

  3. Restart tomcat using previous script. After starting Tomcat, you need to wait 10-20 seconds.

    # /etc/rc.d/rc.tomcat restart

  4. Open http://localhost:8080/cocoon by browser. You'll see Cocoon default page

Create a web application

  1. Open $COCOON_HOME\sitemap.xmap and add pointer to your web application below pipeline

    <!-- ========================= Pipelines =============================== -->
     <map:pipelines>

      <map:pipeline>
        <map:match pattern="app1/**">
        <map:mount uri-prefix="app1"
          src="/home/someone/public_html/app1/sitemap.xmap"
          check-reload="yes" />
        </map:match>
      </map:pipeline>

     
  2. Copy $COCOON_HOME\samples\sitemap.xmap into your web application directory and modify like below

    <?xml version="1.0"?>

    <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
    <!-- =========================== Components ================================ -->

     <map:components>

      <map:matchers default="wildcard"/>
      <map:selectors default="browser"/>

      <map:generators default="file"/>
      <map:transformers default="xslt"/>
      <map:readers default="resource"/>
      <map:serializers default="html"/>

     </map:components>

    <!-- =========================== Views =================================== -->

     <map:views>
      <map:view name="content" from-label="content">
       <map:serialize type="xml"/>
      </map:view>

      <map:view name="pretty-content" from-label="data">

        <map:transform src="common/style/xsl/html/simple-xml2html.xsl"/>
        <map:serialize type="html"/>
      </map:view>
      
      <map:view name="links" from-position="last">
       <map:serialize type="links"/>
      </map:view>

     </map:views>

    <!-- =========================== Pipelines ================================= -->
     <map:pipelines>
      <map:pipeline>

       <map:match pattern="">

        <map:redirect-to uri="index.html"/>
       </map:match>
     
       <map:match pattern="index.html">
         <map:generate src="index.xml"/>
         <map:transform src="style/indexhtml.xsl"/>
         <map:serialize/>

       </map:match>

       <map:match pattern="**.html">
         <map:generate src="{1}.xml"/>
         <map:transform src="style/html.xsl"/>
         <map:serialize/>
       </map:match>

       <map:match pattern="**.pdf">
         <map:generate src="{1}.xml"/>
         <map:transform src="style/pdf.xsl"/>
         <map:serialize type="fo2pdf"/>
       </map:match>

       <map:match pattern="**.xls">
         <map:generate src="{1}.xml"/>
         <map:transform src="style/simple-page2xls.xsl"/>
         <map:serialize type="fo2xls"/>
       </map:match>

       <map:match pattern="**.doc">

         <map:generate src="{1}.xml"/>
         <map:serialize type="fo2rtf"/>
       </map:match>

       <map:match pattern="**.css">
         <map:read mime-type="text/css" src="{1}.css"/>
       </map:match>


       <map:match pattern="**.htm">
         <map:generate type="file" src="{1}.htm"/>
         <map:serialize type="html"/>
       </map:match>

       <!-- ========================= Server ================================ -->

       <map:match pattern="**favicon.ico">
        <map:read src="common/resources/icons/cocoon.ico" mime-type="application/ico"/>
       </map:match>
       
       <!-- ================== Common ======================= -->
       <map:match pattern="*.css">
        <map:read src="common/style/css/{1}.css" mime-type="text/css"/>

       </map:match>

       <map:match pattern="images/*.gif">
        <map:read src="common/resources/images/{1}.gif" mime-type="image/gif"/>
       </map:match>

       <map:match pattern="images/*.jpg">

        <map:read src="common/resources/images/{1}.jpg" mime-type="image/jpg"/>
       </map:match>

       <map:match pattern="images/*.png">
        <map:read src="common/resources/images/{1}.png" mime-type="image/png"/>
       </map:match>

       <!-- samples automount -->  
       <map:match pattern="*/**">
         <map:mount uri-prefix="{1}" src="{1}/" check-reload="yes"/>
       </map:match>

       <map:handle-errors>
        <map:transform src="common/style/xsl/html/error2html.xsl"/>

        <map:serialize type="html" status-code="500"/>
       </map:handle-errors>

      </map:pipeline>
     </map:pipelines>

    </map:sitemap>

    <!-- end of file -->

 

Back

Copyright © [- SroNey / JohN -]. All rights reserved

Hosted by www.Geocities.ws

1