«^»
8 Building a Cocoon application from scratch

The Hello World! example demonstrates that it is easy to transform an XML file into a large number of different formats. It uses a directory structure to keep this organised.

The following instructions show you how to build a subdirectory that has no structure and has the smallest number of files that are needed to do a transformation.

First create a new subdirectory:

cd c:\cocoon-2.1.7\build\webapp
mkdir hwsmall
And then copy some files across:
copy hw\content\hello.xml hwsmall
copy hw\style\xsl\page2html.xsl hwsmall

Now move to the hwsmall subdirectory:

cd hwsmall

In the hwsmall subdirectory, create a file called sitemap.xmap that just has the lines:

0001: <?xml version="1.0"?>
0002: <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
0003:  <map:pipelines>
0004:   <map:pipeline>
0005:    <map:match pattern="">
0006:     <map:generate src="hello.xml"/>
0007:     <map:serialize type="xml"/>
0008:    </map:match>
0009:    <map:match pattern="hello.html">
0010:     <map:generate src="hello.xml"/>
0011:     <map:transform src="page2html.xsl"/>
0012:     <map:serialize type="html"/>
0013:    </map:match>
0014:    <map:match pattern="hello.txt">
0015:     <map:generate src="hello.xml"/>
0016:     <map:serialize type="text"/>
0017:    </map:match>
0018:   </map:pipeline>
0019:  </map:pipelines>
0020: </map:sitemap>
Note: do not include the line numbers (and the colons).

Now use your web browser to go to the URL http://localhost:8888/hwsmall/. That should display the XML. And http://localhost:8888/hwsmall/hello.html should render the XML as HTML. And http://localhost:8888/hwsmall/hello.txt should produce some text.