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ötz
A new version has been created, state: publish
Parts
=====
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)
<p>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
fragements
--- that can be used by other blocks.<br/>
--- Add this pipeline to <tt>myblock2</tt>. It provides a transformation service
--- that consists of two XSLT transformation steps:</p>
+++ that can be used by other blocks:</p>
--- <pre>TBD</pre>
+++ <pre><?xml version="1.0" encoding="UTF-8"?>
+++ <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+++ <map:pipelines>
+++ <map:pipeline>
+++ <map:match pattern="callingTransformationService">
+++ <map:generate src="demo/welcome.xml"/>
+++ <strong><map:transform type="servletService">
+++ <map:parameter name="service"
+++ value="servlet:myBlock2:/myXsltTransformation-service"/>
+++ </map:transform></strong>
+++ <map:serialize type="xml"/>
+++ </map:match>
+++ </map:pipeline>
+++ </map:pipelines>
+++ </map:sitemap></pre>
--- <p>Now it can be used from myBlock1</p>
+++ <p>When the requests arrives at <tt>callingTransformationService</tt>
pipeline,
+++ the generator produces SAX events of <tt>demo/welcome.xml</tt>. There is
nothing
+++ special here. The interesting part comes with the following transformer of
type
+++ <tt>servletService</tt>. It calls a transformation service which is
provided by
+++ <tt>myBlock2</tt>.</p>
--- <pre>TBD</pre>
+++ <p>Add this service to the sitemap of myBlock2
+++
(<tt>getting-started-app/myBlock2/src/main/resources/COB-INF/sitemap.xmap)</tt>.
+++ It consists of one XSLT transformation step:</p>
--- <p>...</p>
+++ <pre><?xml version="1.0" encoding="UTF-8"?>
+++ <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+++ <map:pipelines>
+++ <map:pipeline>
+++ <map:match
pattern="<strong>myXsltTransformation-service</strong>">
+++ <map:generate src="<strong>service-consumer:</strong>"/>
+++ <map:transform src="myXsltTransformation.xslt"/>
+++ <map:serialize type="xml"/>
+++ </map:match>
+++ </map:pipeline>
+++ </map:pipelines>
+++ </map:sitemap></pre>
+++ <p>The generator uses the service-consumer protocol which initializes the
+++ service. Then the pipeline continues with an XSLT transformation
+++ <tt>myXsltTranformation.xslt</tt>, which has to be put into the same
directory
+++ as the <tt>myBlock2</tt> sitemap:</p>
+++
+++ <pre><?xml version="1.0" encoding="UTF-8"?>
+++ <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+++ <xsl:template match="/">
+++ <html>
+++ <head>
+++ <title>Output of the XSLT transformation
service.</title>
+++ </head>
+++ <body>
+++ Output of the XSLT transformation service.
+++ </body>
+++ </html>
+++ </xsl:template>
+++ </xsl:stylesheet>
+++ </pre>
+++
+++ <p>Point your browser at
+++ <tt>http://localhost:8888/myBlock1/callingTransformationService</tt> and
see the
+++ output of the pipeline.</p>
+++
+++ <p class="note">Beside transformation services there are also generation
and a
+++ serialization services.</p>
+++
</body>
</html>