1 Understanding Cocoon2 Pankaj Kumar May 24, 2001 Web Services Organization HPMD, SSO, HP.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
1 Build a Web Application on J2EE. 2 J2EE Scenario Client – Web Server – EIS Resources Client – Web Server – EIS Resources Client – Application Server.
Tomcat Configuration A Very, Very, Very Brief Overview.
JSP Architecture  JSP is a simple text file consisting of HTML or XML content along with JSP elements  JSP packages define the interface for the compiled.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
ECE356 – Database Systems Lab 1 – Building a Web Project with NetBeans Tiuley Alguindigue Lab Instructor – University of Waterloo, E & CE Dept. Fall 2013.
Java Servlets and JSP.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Quick Tour of the Web Technologies: The BIG picture LECTURE A bird’s eye view of the different web technologies that we shall explore and study.
UNIT-V The MVC architecture and Struts Framework.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
XML for E-commerce IV Helena Ahonen-Myka. In this part... n Some solutions for delivering dynamic content n Example of using XML.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
JSP Standard Tag Library
Applets & Servlets.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
CPS120: Introduction to Computer Science The World Wide Web Nell Dale John Lewis.
SDPL 2002Notes 7: Apache Cocoon1 7 XML Web Site Architecture Example: Apache Cocoon, a Web publishing architecture based on XML technology
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
WORKING WITH XSLT AND XPATH
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Dynamic Data Exchanges with the Java Flow Processor Presenter: Scott Bowers Date: April 25, 2007.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Introduction to Java Server Pages (JSPs) Robert Thornton.
Building XML Portals with Cocoon M atthew Langham S&N AG
DSpace UI Alexey Maslov. DSpace in general A digital library tool useful for storage, maintenance, and retrieval of digital documents Two types of interaction:
Rendering Contexts and Components What is a uPortal3 context ? –Defines all aspects of a traditional portal instance Design, navigation, profiles Parameter.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
March 28, 2001XSP Session O’Reilly Enterprise Java Conference 1 XSP Session Sue Spielman President/Consulting Engineer President/Consulting Engineer
WEB BASED DATA TRANSFORMATION USING XML, JAVA Group members: Darius Balarashti & Matt Smith.
SDPL 2001Notes 7.2: Apache Cocoon1 7.2 Apache Cocoon An example of a Web publishing architecture based on XML technology An.
Apache Cocoon Part I 2/27/06 Kevin Davis. Learning Objectives Understand the function of Cocoon Create a working sitemap Make available a stylesheet-
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
The HTTP is a standard that all Web browsers and Web servers must speak in order for the Web portion of the Internet to work.
Struts 2 introduction. Struts 2 framework Struts 2 A full-featured web application framework for the Java EE platform The Java Servlet API exposes the.
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
AxKit A member of the Apache XML project Ryan Maslyn Kyle Bechtel.
1 Introduction to Web Applications & APIs. 2 Agenda  Architecture of Web Applications Three layer architecture  Web Server (Tomcat) Installation Data.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
©2001 Priority Technologies, Inc. All Rights Reserved Meteor Status Miami Face to Face Meeting January 16 – 18, 2002.
Cocoon An XML Web Publishing Framework From the Apache Project Roland Schweitzer.
ASP.NET – Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework.
Basic web application development with Apache Cocoon Basic web application development with Apache Cocoon 2.1 Jasha Joachimsthal Jeroen.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
Apache Struts Technology A MVC Framework for Java Web Applications.
Apache Cocoon – XML Publishing Framework 데이터베이스 연구실 박사 1 학기 이 세영.
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
Unit 4 Representing Web Data: XML
Creating Novell Portal Services Gadgets: An Architectural Overview
Processes The most important processes used in Web-based systems and their internal organization.
Knowledge Byte In this section, you will learn about:
Cocoon: A Framework for Web Services
Prepared for Md. Zakir Hossain Lecturer, CSE, DUET Prepared by Miton Chandra Datta
Chapter 7 Representing Web Data: XML
An XML Web Publishing Framework From the Apache Project
A Match Made In (Ethereal) Heaven
Presentation transcript:

1 Understanding Cocoon2 Pankaj Kumar May 24, 2001 Web Services Organization HPMD, SSO, HP

2 Prerequisites What You Should know... –XML, XML Namespaces –Basics of XPath, XSLT –Java language –Servlets, HTTP What You need not know … –Cocoon 1

3 Agenda A Little History What problem does Cocoon2 solve? Basic Mechanisms Cocoon2 Architecture Cocoon2 Abstractions How do I use Cocoon? An Example eXtensible Server Pages ( XSPs ) Sitemap Matchers Generators Transformers Aggregators Serializers Pipeline processing Logicsheets Cocoon configuration Context

4 A Little History Cocoon 1... –Cocoon project was founded in Jan by Stefano Mazzocchi as an open source project under Apache Software Foundation. –Started as a simple servlet for XSL styling of XML content. –Was based on DOM level 1 API. This choice turned out to be quite limiting for speed/memory efficiency. –Used reactor pattern to connect components. This allowed the reaction instructions to be placed inside the documents. Though appealing, it caused difficulties in managing highly dynamic web-sites. –Allowed context overlap to happen by having processing instructions in documents/stylesheets.

5 A Little History ( Contd. ) Cocoon 2... –A separate codebase to incorporate Cocoon1 learnings. –Designed for execution speed/memory efficiency and scalability to process very large documents by switching processing model from DOM to SAX. –Centralizes the management functions by allowing processing pipeline specification in a sitemap ( an XML file ), replacing the embedded processing instruction model. –Better support for pre-compilation, pre-generation and caching for better performance. –Current status: Alpha quality code. Available only in source form directly from CVS.

6 Basic problem to be solved: What Problem does Cocoon2 solve? Separation of content, style, logic and management functions in an XML content based web site ( and web services ). Data Mapping XML Relational Object XML Relational Object Other

7 Basic mechanisms Basic mechanisms for processing XML documents: –Dispatching based on Matchers. –Generation of XML documents ( from content, logic, Relation DB, objects or any combination ) through Generators –Transformation (to another XML, objects or any combination ) of XML documents through Transformers –Aggregation of XML documents through Aggregators –Rendering XML through Serializers Generator Transformer Aggregator Serializer request stylesheet

8 Cocoon Pipeline Processing Sequence of interactions Cocoon pipeline

9 Cocoon2 Architecture Core-Cocoon Cocoon-Components Built-in logicsheets Site specific configuration, components, logicsheets and content Avalon framework for logging, configuration, threading, context etc. Cacheing mechanism Pipeline handling Program generation, compilation, loading and execution. Base classes for generation, transformation, serialization, … components.... Specific generators Specific transformers Specific matchers Specific serializers... sitemap.xsl xsp.xsl esql.xsl request.xsl response.xsl...

10 Cocoon2 Abstractions eXtensible Server Pages ( XSPs ) Sitemap Matchers Generators Transformers Serializers Pipeline processing Logicsheets Cocoon configuration Context

11 eXtensible Server Pages ( XSPs ) An XSP page is an XML page with following requirements: –The document root must be –It must have language declaration as an attribute in the element. –It must have namespace declaration for xsp as an attribute in the element. –For an XSP to be useful, it must also require at least an and an element. An XSP page is used by a generator to generate XML document. <xsp:page language="java" xmlns:xsp=" static private int counter = 0; private synchronized int count() { return counter++; } I have been requested count() times. A Simple XSP Page

12 XSP Processing ( Code Generation ) package org.apache.cocoon. import java.io.File; // A bunch of other imports … public class counter_xsp extends XSPGenerator { //.. Bookkeepig stuff commented out. /* User Class Declarations */ static private int counter = 0; private synchronized int count() { return counter++; } /* Generate XML data. */ public void generate() throws SAXException { this.contentHandler.startDocument(); AttributesImpl xspAttr = new AttributesImpl(); this.contentHandler.startPrefixMapping("xsp", " this.contentHandler.startElement("", "page", "page", xspAttr); // Statements to build the XML document ( Omitted ) this.contentHandler.endElement("", "page", "page"); this.contentHandler.endPrefixMapping("xsp"); this.contentHandler.endDocument(); }

13 Ways of Creating XSPs Embedded Logic –Code is embedded in the XML page –No separation of content and logic –Okay for small examples but terrible for large systems.... Functions.. … function calls … … xml... … stylesheet... … html... page.xsp page-html.xsl page.html

14 Ways of Creating XSPs ( Contd. ) Included Logicsheet –Code is in a separate logicsheet ( an XSL file) –Effective separation of content and logic –Preferred way to create XSPs Functions.. … function calls … … xml... … stylesheet... … html... page-xsp.xsl page-html.xsl page.html … … … page.xml … xsp...

15 Ways of Creating XSPs ( Contd. ) Logicsheet as tag library –The logicsheet is packaged as a reusable tag library and registered with Cocoon in cocoon.xconf file. –Tag library has a namespace declaration, declared in the original logicsheet and matched in xmlns: … attribute. –Effective separation of content, logic and management <xsl:stylesheet … xmlns:ilib=“…” > … function calls … … xml... … stylesheet... … html... ilib.xsl page-html.xsl page.html <xsp:page … xmlns:ilib=“…”> … … page.xml … xsp... cocoon.xconf...

16 Sitemap Sitemap contains configuration information for a Cocoon engine: –list of matchers –list of generators –list of transformers –list of readers –list of serializers –list of selectors –list of processing pipelines with match patterns –... Sitemap is an XML file corresponding to a sitemap DTD. Sitemap can be edited to add new elements. Sitemap is generated into a program and is compiled into an executable unit. … … … … … … Sitemap.xmap structure

17 Matchers A Matcher attempts to match an URI with a specified pattern for dispatching the request to a specific processing pipeline. Different types of matchers: –wildcard matcher –regexp matcher More matchers can be added without modifying Cocoon. Matchers help in specifying a specific pipeline processing for a group of URIs. Sitemap entries for different types of matchers... … </map:match Pipeline entries in sitemap file

18 Generators A Generator is used to create an XML structure from an input source ( file, directory, stream …) Different types of generators: –file generator –directory generator –XSP generator –JSP generator –Request generator –…–… More generators can be added without modifying Cocoon.... Sitemap entries for different types of generators A sample generator entries in a pipeline

19 Generators ( Contd. ) A Generator turns an XML document, after applying appropriate transformations, into a compiled program whose output is an XML document. An XSP generator applies all the logicsheets specified in the source XML file before generating the program. Generators cache the compiled programs for better runtime efficiency. Input.java Input.class program Generator compilation execution Input tree Output tree Program generation

20 Transformers A Transformer is used to map an input XML structure into another XML structure. Different types of transformers: –XSLT Transformer –Log Transformer –SQL Transformer –I18N Transformer –…–… Log Transformer is a good debugging tool. More transformers can be added without modifying Cocoon.... Sitemap entries for different types of transformers A sample transformer entry in a pipeline

21 Serializers A Serializer is used to render an input XML structure into some other format ( not necessarily XML ) Different types of serializers: –HTML Serializer –FOP Serializer –Text Serializer –XML Serializer –…–… More serializers can be added without modifying Cocoon. … Sitemap entries for different types of serializers A sample serializer entry in a pipeline

22 Pipeline Processing The sitemap configuration allows dynamic setup of processing pipelines consisting of a generator, multiple transformers and a serializer. Requests are dispatched to a pipeline based on request URI and the pipeline matching pattern ( either with wildcards or as a regexp ) The pipeline is setup in the generated file sitemap_xmap.java ( This file gets generated [ possibly asynchronously] everytime the sitemap.xmap is modified. File Generator XSL Transformer HTML Serializer hello-page.xml hello.html simple-page2html.xsl

23 Logicsheets Logicsheets are XSL files with an associated namespace. Primary mechanism to add program logic ( code ) to XSPs. These need to be registered in configuration file cocoon.xconf. Logicsheets are used by the generator to transform XML structure before generating program. Cocoon comes with a no. of built- in logic sheets: –request.xsl –response.xsl –session.xsl –cookie.xsl –esql.xsl –log.xsl –…. … variable and xsp:logic statements... if(getLogger() != null) getLogger().debug(" ");... Log.xsl structure <xsp:page language="java" xmlns:xsp=" xmlns:log=" Test Message A sample use

24 Cocoon Configuration Cocoon is highly configurable. Main configuration files, assuming Cocoon deployment as a servlet in a servlet container, are ( directory locations assume Tomcat servlet container and Windows NT ): –sitemap.xmap : the sitemap file. By default, located in %TOMCAT_HOME%\webapps\cocoon directory. –cocoon.xconf : configuration file having logicsheet registrations. Specifies, sitemap.xmap location and other such parameters. By default, located in %TOMCAT_HOME%\webapps\cocoon directory. –web.xml : servlet deployment descriptor. Specifies location of cocoon.xconf, log file location and other such parameters. Located in %TOMCAT_HOME%\webapps\cocoon\Web-inf directory. –cocoon.roles: mapping file for Core Cocoon components name and implementation classes. For example, if you want to use a parser other than the default one, you need to modify this file.

25 Cocoon Work Area Cocoon produces execution log entries for debugging/auditing. –The amount of data to be logged can be controlled by log-level parameter in web.xml file. The default is DEBUG ( maximum data ). –By default, the log file is: %TOMCAT_HOME%\webapps\cocoon\Web- inf\logs\cocoon.log. Cocoon keeps the generated.java files in a directory tree starting at ( by default ): %TOMCAT_HOME%\webapps\work\localhost_8080%2Fcoc oon\org\apache\cocoon\www. You can find sitemap_xmap.java here. Files created by LogTransformer are kept ( by default ) in %TOMCAT_HOME% directory.

26 How do I use Cocoon with Tomcat Download Tomcat from Apache site. Download Cocoon sources from Apache CVS ( binaries not available for Cocoon2 yet ). Would require socksified CVS client for connection setup. [ Command assume UNIX shell prompt ] export cvs login Password: anoncvs cvs checkout xml-cocoon2 Alternatively download it from our own Cocoon2 CVS archive ( synchronized daily with Apache CVS ) export cvs login Password: cvs cvs -z 9 checkout Cocoon2 Build sources as per instruction in Install file. Move the cocoon.war file to %TOMCAT_HOME%\webapps directory. Start the servlet engine. Type-in the URL in your browser. You should see the Cocoon welcome message. Consult Install file if you face problems.

27