Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

XML IV: Cocoon 2.

Ähnliche Präsentationen


Präsentation zum Thema: "XML IV: Cocoon 2."—  Präsentation transkript:

1 XML IV: Cocoon 2

2 Concrete Event Handler A Concrete Event Handler B
The Reactor Pattern Das Reactor Pattern ermöglicht Demultiplexing und Verteilung von Service Requests bei ereignisgesteuerten Anwendungen. Handle owns dispatches * notifies handle set Reactor handle_events() register_handler() remove_handler() Event Handler handle_event () get_handle() Concrete Event Handler A Concrete Event Handler B Synchronous Event Demuxer select () <<uses>>

3 The Reactor Pattern : Main Program : Concrete Event Handler : Reactor
: Synchronous Event Demultiplexer register_handler() get_handle() handle_events() select() handle_event() Handle Handles Con. Event Handler Events service() event

4 Architektur Webserver Servlet Container Serializer Transform Generator
DB wml html pdf Serializer Transform Generator

5 Pyramiden Modell von Web Verträgen
Management: Pfade, Verteilung, Regeln, Organisation Logic: dynamische Generierung Content: Seiten Inhalt Style: Layout

6 Grundkonzept Pipeline
Umleitung nach Muster Erzeugung des XML Dokuments Transformation Ausgabe, Erzeugung von spez. Formaten (html, pdf, wml, usw.)

7 Pipeline

8 Architektur Core: configuration,threading, context,
caching, pipeline handling, program generation, compilation, loading and execution. Components: generators, transformers matchers, serializers

9 Sitemap <?xml version="1.0"?> <map:components/>
<map:sitemap xmlns:map= "http://apache.org/cocoon/sitemap/1.0"> <map:components/> <map:views/> <map:resources/> <map:pipelines/> <map:action-sets/> </map:sitemap> JAVA Program Action

10 Sitemap II <map:components> <map:generators/>
<map:transformers/> <map:serializers/> <map:readers/> <map:selectors/> <map:matchers/> <map:actions/> </map:components> JAVA Program Action

11 Anwendung Legi 1.) Legi Daten von Studenten in ausgeben.
xml  html legi_html.xsl xml  pdf legi_pdf.xsl xml  ps ? xml  wml legi_wml.xsl

12 Sitemap Legi I <?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> <!-- =========================== Components ================================ --> <map:components> <map:generators default="file"/> <map:transformers default="xslt"/> <map:readers default="resource"/> <map:serializers default="html"/> <map:selectors default="browser"/> <map:matchers default="wildcard"/> <map:serializer name="fo2ps" src="org.apache.cocoon.serialization.FOPSerializer" mime-type="application/postscript"/> <map:serializer name="fo2pdf" src="org.apache.cocoon.serialization.FOPSerializer" mime-type="application/pdf"/> <map:serializer name="wap" mime-type="text/vnd.wap.wml" src="org.apache.cocoon.serialization.XMLSerializer"> <doctype-public>-//WAPFORUM//DTD WML 1.1//EN</doctype-public> <doctype-system>http://www.wapforum.org/DTD/wml_1.1.xml</doctype-system> <encoding>ASCII</encoding> <omit-xml-declaration>yes</omit-xml-declaration> </map:serializer> </map:components> <!-- =========================== Pipelines ================================= -->

13 Sitemap Legi II … <map:match pattern="*.*.html">
<map:generate src="xml/{1}.{2}.xml"/> <map:transform src="xsl/legi_html.xsl"/> <map:serialize type="html"/> </map:match> <map:match pattern="*.*.pdf"> <map:transform src="xsl/legi_pdf.xsl"/> <map:serialize type="fo2pdf"/> <map:match pattern="*.*.ps"> <map:serialize type="fo2ps"/> <map:match pattern="*.*.wml"> <map:transform src="xsl/legi_wml.xsl"/> <map:serialize type="wap"/>

14 Anwendung Portalseite
Alle Dienste einer Seite sollen aufgelistet werden. 1.) ““  welcome 2.) welcome  samples.xml  simple-samples2html.xsl  html 3.) Sitemap für Links

15 samples.xml <?xml version="1.0" encoding="iso-8859-1"?>
<samples xmlns:xlink="http://www.w3.org/1999/xlink"> <group name="Multimedia Hello World"> <sample name="HTML" href="hello.html"> This is a very simple demonstration of how to use Cocoon. A simple XML page is transformed into an HTML page. </sample> <sample name="WML" href="hello.wml"> Now something more juicy: the exact same page is translated into WAP WML. <sample name="SVG" href="hello.svg"> Need a fancier look? No problem, SVG is your friend.

16 Sitemap <map:pipeline> <map:match pattern="">
<map:redirect-to uri="welcome"/> </map:match> <map:match pattern="welcome"> <map:generate src="docs/samples/samples.xml"/> <map:transform src="stylesheets/simple-samples2html.xsl"/> <map:serialize/> <map:match pattern="hello.html"> <map:generate src="docs/samples/hello-page.xml"/> <map:transform src="stylesheets/page/simple-page2html.xsl"/> <map:serialize type="html"/> <map:match pattern="hello.wml"> <map:transform src="stylesheets/page/simple-page2wml.xsl"/> <map:serialize type="wap"/>

17 Browser spezifische Seite
<map:select> <map:when test="wap"> <map:transform src="stylesheets/simple-samples2wap.xsl"/> </map:when> <map:when test="netscape"> <map:transform src="stylesheets/simple-samples2netscape.xsl"/> <map:otherwise> <map:transform src="stylesheets/simple-samples2html.xsl"/> </map:otherwise> </map:select>

18 eXtensible Server Pages (XSPs)
Analog zu JSP nur Trennung von Code Logic Presentation

19 eXtensible Server Pages (XSPs)
<?xml version="1.0" encoding="ISO "?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp"> <xsp:logic> static private int counter = 0; private synchronized int count() { return counter++; } </xsp:logic> <page> <p>I have been requested <xsp:expr>count()</xsp:expr> times.</p> </page> </xsp:page>

20 XSP Bsp. II <?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:xsp-request="http://apache.org/xsp/request/2.0" xmlns:log="http://apache.org/xsp/log/2.0" xmlns:capture="http://apache.org/cocoon/capture/1.0"> <page> <log:logger name="xsp-sample" filename="xsp-sample.log"/> <log:debug>jax: start jax page</log:debug> <title>A Simple XSP Page</title> <content> <capture:fragment-variable name="page_part"> <para>These 2 paragraphs were generated at the start of the XSP, and captured for insertion at the end.</para> <para>Brought to you by Cocoon2 at <xsp:expr>new Date()</xsp:expr>.</para> </capture:fragment-variable> <para>I was requested as the URI: <b><xsp-request:get-uri as="xml"/></b></para>

21 XSP Bsp. II <para>The following list was dynamically generated:</para> <ul> <xsp:logic> <![CDATA[ for (int i=0; i<3; i++) { ]]> <li> Punkt: <xsp:expr>i</xsp:expr> </li> } </xsp:logic> </ul> <xsp-request:get-parameter-values name="name"/> <xsp-request:get-parameter-names/> <para> Header "user-agent" as String: <xsp-request:get-header name="user-agent"/> </para> <xsp:expr>page_part</xsp:expr> </content> <log:debug>Processing the end of the JAX page</log:debug> </page> </xsp:page>

22 Links Praktikum Installation Cocoon Legi mit pdf,html, wml Ausgabe
Praktikum Installation Cocoon Legi mit pdf,html, wml Ausgabe einfach XSP-Seite

23 Download Tomcat 4.0

24 Installieren

25 Ordner Struktur

26 Download Cocoon

27 Extracting cocoon.war Apache Tomcat 4.0\webapps

28 Test: Start Tomcat


Herunterladen ppt "XML IV: Cocoon 2."

Ähnliche Präsentationen


Google-Anzeigen