cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@cocoon.zones.apache.org
Subject [DAISY] Updated: Your first XML pipeline (publishing)
Date Sat, 05 May 2007 12:31:46 GMT
A document has been updated:

http://cocoon.zones.apache.org/daisy/documentation/1290.html

Document ID: 1290
Branch: main
Language: default
Name: Your first XML pipeline (publishing) (previously Your first XML pipeline)
Document Type: Cocoon Document (unchanged)
Updated on: 5/5/07 12:31:23 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: 8304 bytes (previous version: 2927 bytes)
Content diff:
    <html>
    <body>
    
+++ <p class="fixme">The archetype has to use Maven deployer by default.</p>
+++ 
+++ <p class="fixme">The first tutorial should be split into two parts: one that
+++ only creates a block and a second one, that creates a war. That tutorial should
+++ be stand alone because it is too much to introduce this concept there too IMHO
+++ (rpoetz).</p>
+++ 
+++ <p class="fixme">The first tutorial should introduce into cocoon:rcl so that
+++ Cocoon becomes useable right away.</p>
+++ 
+++ <p class="fixme">The first tutorial should be renamed.</p>
+++ 
    <p>This tutorial is based on the <a href="daisy:1159">"Your first Cocoon
    application using Maven 2" guide</a> which shows how to bootstrap a Cocoon
    project.</p>
(24 equal lines skipped)
    
    <p>First, open <tt>src\main\resources\COB-INF\sitemap.xmap</tt> in your
favorite
    XML editor. That's your block's base sitemap. There are already some pipelines
--- there (<tt>/sitemap/pipelines</tt>) but for this purpose of this tutorial,
let's
+++ there (<tt>/sitemap/pipelines</tt>) but for the sake of this tutorial, let's
    create your own pipeline.</p>
    
    <pre>&lt;map:sitemap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
(3 equal lines skipped)
    
      &lt;map:pipelines&gt;
    <strong>    &lt;map:pipeline&gt;
---       &lt;map:match pattern="myFirstPipeline"&gt;
---         &lt;map:generate src="myXmlFile.xml"/&gt;
+++ <strong>      &lt;map:match pattern="myFirstPipeline"&gt;
+++         &lt;map:generate src="myXmlFile.xml" type="file"/&gt;
            &lt;map:serialize type="xml"/&gt;
---       &lt;/map:match&gt;
+++       &lt;/map:match&gt;</strong>
        &lt;/map:pipeline&gt;</strong>
        [...]
      &lt;/map:pipelines&gt;
(24 equal lines skipped)
    
    <h1>Adding an XSLT transformation step</h1>
    
--- <p>TBD</p>
+++ <p>The first pipeline wasn't really exciting, just reading some XML file and
+++ serializing it without changing anything. The second example will add a
+++ transformation step based on <a href="http://www.w3.org/TR/xslt">XSLT</a>:</p>
    
--- <h1>Using XML templates</h1>
+++ <pre>&lt;map:sitemap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+++  xsi:schemaLocation="http://apache.org/cocoon/sitemap/1.0 
+++   http://cocoon.apache.org/schema/sitemap/cocoon-sitemap-1.0.xsd"
+++  xmlns:map="http://apache.org/cocoon/sitemap/1.0"&gt;
    
--- <p>TBD</p>
+++   &lt;map:pipelines&gt;
+++     &lt;map:pipeline&gt;<strong>
+++ </strong>      &lt;map:match pattern="myFirstPipeline"&gt;
+++         &lt;map:generate src="myXmlFile.xml" type="file"/&gt;
+++         &lt;map:serialize type="xml"/&gt;
+++       &lt;/map:match&gt;<strong>
+++ </strong><strong><strong><strong>      &lt;map:match pattern="mySecondPipeline"&gt;
+++         &lt;map:generate src="myXmlFile.xml" type="file"/&gt;
+++ </strong></strong><strong><strong><strong><strong>
       &lt;map:transform src="myXsltFile.xslt" type="xslt"/&gt;</strong></strong></strong></strong>
+++ <strong><strong>        &lt;map:serialize type="html"/&gt;
+++       &lt;/map:match&gt;</strong></strong></strong>
+++     &lt;/map:pipeline&gt;
+++     [...]
+++   &lt;/map:pipelines&gt;
    
+++ &lt;/map:sitemap&gt;</pre>
+++ 
+++ <p>The XSLT file is very simple and creates an XML following the structure of
+++ XHTML (though without using any namespaces in order to keep things simple):</p>
+++ 
+++ <pre>... [put the stylesheet here]</pre>
+++ 
+++ <p>After saving the sitemap and the XSLT file, you can point you browser to
+++ <tt>http://localhost:8888/myBlock</tt><tt><tt>1</tt>/mySecondPipeline</tt>
and
+++ you will see the output, this time its HTML because of the use of the HTML
+++ serializer.</p>
+++ 
+++ <p class="note">In this tutorial you have already implemented two pipelines but
+++ there is only one pipeline element used in the sitemap. Given this is confusing
+++ when you use Cocoon sitemaps the first time. However, there is a reason for
+++ this: The <tt>&lt;pipeline&gt; </tt>element indicates which <em>pipeline
+++ implementation</em> is used. If there is no <tt>@type</tt> attribute,
the
+++ generators, tranformers and serializers are invoked from a caching pipeline
+++ implementation. <br/>
+++ When Cocoon developers talk about pipelines, they mean a series of a matcher
+++ that includes at least a generator and a serializer. Transformers and other
+++ sitemap components are optional.</p>
+++ 
+++ <h1>Creating a PDF</h1>
+++ 
+++ <p>The first example created XML and the second one HTML. One of the strength of
+++ Cocoon is that it makes it very simple to support many different output formats.
+++ The result of this third example will be a PDF, again based on
+++ <em>myXmlFile.xml</em>:</p>
+++ 
+++ <pre>&lt;map:sitemap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+++  xsi:schemaLocation="http://apache.org/cocoon/sitemap/1.0 
+++   http://cocoon.apache.org/schema/sitemap/cocoon-sitemap-1.0.xsd"
+++  xmlns:map="http://apache.org/cocoon/sitemap/1.0"&gt;
+++ 
+++   &lt;map:pipelines&gt;
+++     &lt;map:pipeline&gt;<strong>
+++ </strong>      &lt;map:match pattern="myFirstPipeline"&gt;
+++         &lt;map:generate src="myXmlFile.xml" type="file"/&gt;
+++         &lt;map:serialize type="xml"/&gt;
+++       &lt;/map:match&gt;<strong>
+++ </strong>      &lt;map:match pattern="mySecondPipeline"&gt;
+++         &lt;map:generate src="myXmlFile.xml" type="file"/&gt;
+++         &lt;map:transform src="myXsltFile.xslt" type="xslt"/&gt;
+++         &lt;map:serialize type="html"/&gt;
+++       &lt;/map:match&gt;<strong><strong><strong>
+++ </strong></strong></strong><strong><strong><strong>
     &lt;map:match pattern="myThirdPipeline"&gt;
+++         &lt;map:generate src="myXmlFile.xml" type="file"/&gt;
+++ </strong></strong><strong><strong><strong><strong>
       &lt;map:transform src="myXml2PdfFile.xslt" type="xslt"/&gt;</strong></strong></strong></strong>
+++ <strong><strong>        &lt;map:serialize type="fop"/&gt;
+++       &lt;/map:match&gt;</strong></strong></strong>
+++     &lt;/map:pipeline&gt;
+++     [...]
+++   &lt;/map:pipelines&gt;
+++ 
+++ &lt;/map:sitemap&gt;</pre>
+++ 
+++ <p>This pipeline needs a different XSLT file which transforms the XML of
+++ myXmlFile.xml to some XML that can be used by
+++ <a href="http://xmlgraphics.apache.org/fop/">FOP</a> to create PDF:</p>
+++ 
+++ <pre>... [put the stylesheet here]</pre>
+++ 
+++ <p>You also have to use a different serializer for this example, a serializer
+++ that can use the XML created by the stylesheet and produce PDF based on it.
+++ Cocoon ships this serializer as part of the FOP block. Since the block that you
+++ created probably doesn't have the FOP block added as dependency, this has to be
+++ done before you can test your pipeline. Adding a block requires editing the
+++ pom.xml of your block:</p>
+++ 
+++ <pre>... [put the pom.xml here]</pre>
+++ 
+++ <p>Rebuild your block:</p>
+++ 
+++ <pre>mvn compile</pre>
+++ 
+++ <p>and start the servlet container again:</p>
+++ 
+++ <pre>mvn jetty:run</pre>
+++ 
+++ <p>Now you can point your browser at
+++ <tt>http://localhost:8888/myBlock</tt><tt><tt>1</tt>/myThirdPipeline</tt>
and
+++ you will get a PDF as result.</p>
+++ 
    </body>
    </html>


Mime
View raw message