Return-Path: Delivered-To: apmail-cocoon-docs-archive@www.apache.org Received: (qmail 62254 invoked from network); 28 May 2007 16:28:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 May 2007 16:28:26 -0000 Received: (qmail 81487 invoked by uid 500); 28 May 2007 16:28:30 -0000 Delivered-To: apmail-cocoon-docs-archive@cocoon.apache.org Received: (qmail 81468 invoked by uid 500); 28 May 2007 16:28:30 -0000 Mailing-List: contact docs-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: docs@cocoon.apache.org List-Id: Delivered-To: mailing list docs@cocoon.apache.org Received: (qmail 81457 invoked by uid 99); 28 May 2007 16:28:30 -0000 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.67] (HELO cocoon.zones.apache.org) (140.211.11.67) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 May 2007 09:28:30 -0700 Message-ID: <15972610.1180369685816.JavaMail.daisy@cocoon.zones.apache.org> Date: Mon, 28 May 2007 16:28:05 +0000 (GMT+00:00) From: daisy@cocoon.zones.apache.org To: docs@cocoon.apache.org Subject: [DAISY] Updated: Modularize Cocoon apps (Using blocks) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org A document has been updated: http://cocoon.zones.apache.org/daisy/documentation/1291.html Document ID: 1291 Branch: main Language: default Name: Modularize Cocoon apps (Using blocks) (unchanged) Document Type: Cocoon Document (unchanged) Updated on: 5/28/07 4:27:58 PM Updated by: Reinhard P=C3=B6tz A new version has been created, state: publish Parts =3D=3D=3D=3D=3D Content ------- This part has been updated. Mime type: text/xml (unchanged) File name: (unchanged) Size: 7881 bytes (previous version: 5391 bytes) Content diff: (143 equal lines skipped) =20

The previous example showed how you can call a pipeline from another= block. But here is even more you can do! A sitemap can also provide pipeline f= ragements --- that can be used by other blocks.
--- Add this pipeline to myblock2. It provides a transformation se= rvice --- that consists of two XSLT transformation steps:

+++ that can be used by other blocks:

=20 ---
TBD
+++
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
+++ <map:sitemap xmlns:map=3D"http://apache.org/cocoon/sitemap/1.0">
+++   <map:pipelines>
+++     <map:pipeline>
+++       <map:match pattern=3D"callingTransformationService">
+++         <map:generate src=3D"demo/welcome.xml"/>
+++         <map:transform type=3D"servletService">
+++           <map:parameter name=3D"service"=20
+++            value=3D"servlet:myBlock2:/myXsltTransformation-service"/>=
;
+++         </map:transform>
+++         <map:serialize type=3D"xml"/>
+++       </map:match>
+++     </map:pipeline>
+++   </map:pipelines>
+++ </map:sitemap>
=20 ---

Now it can be used from myBlock1

+++

When the requests arrives at callingTransformationService p= ipeline, +++ the generator produces SAX events of demo/welcome.xml. There i= s nothing +++ special here. The interesting part comes with the following transformer= of type +++ servletService. It calls a transformation service which is pro= vided by +++ myBlock2.

=20 ---
TBD
+++

Add this service to the sitemap of myBlock2 +++ (getting-started-app/myBlock2/src/main/resources/COB-INF/sitemap.xm= ap). +++ It consists of one XSLT transformation step:

=20 ---

...

+++
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
+++ <map:sitemap xmlns:map=3D"http://apache.org/cocoon/sitemap/1.0">
+++   <map:pipelines>
+++     <map:pipeline>
+++       <map:match pattern=3D"myXsltTransformation-service">
+++         <map:generate src=3D"service-consumer:"/>=
;
+++         <map:transform src=3D"myXsltTransformation.xslt"/>
+++         <map:serialize type=3D"xml"/>
+++       </map:match>
+++     </map:pipeline>
+++   </map:pipelines>
+++ </map:sitemap>
=20 +++

The generator uses the service-consumer protocol which initializes t= he +++ service. Then the pipeline continues with an XSLT transformation +++ myXsltTranformation.xslt, which has to be put into the same di= rectory +++ as the myBlock2 sitemap:

+++=20 +++
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
+++ <xsl:stylesheet version=3D"1.0" xmlns:xsl=3D"http://www.w3.org/1999/=
XSL/Transform">
+++ =C2=A0 <xsl:template match=3D"/">
+++ =C2=A0=C2=A0=C2=A0 <html>
+++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <head>
+++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <title>Output of the X=
SLT transformation service.</title>
+++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </head>
+++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <body>
+++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Output of the XSLT transform=
ation service.
+++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </body>
+++ =C2=A0=C2=A0=C2=A0 </html>
+++ =C2=A0 </xsl:template>
+++ </xsl:stylesheet>
+++ 
+++=20 +++

Point your browser at +++ http://localhost:8888/myBlock1/callingTransformationService an= d see the +++ output of the pipeline.

+++=20 +++

Beside transformation services there are also generat= ion and a +++ serialization services.

+++=20