«^»
5 Testing Cocoon

Now start up a web browser and visit the URL http://localhost:8888/.

Hopefully you will get a page displayed saying:

Welcome to Apache Cocoon!
Congratulations! If you are reading this page, 
it means that your Apache Cocoon installation was successful.
To know more about Cocoon capabilities, look at the samples 
...

If you click on the link behind the word samples, you will be taken to the page http://localhost:8888/samples/.

If you then click on Hello World!, you will be taken to http://localhost:8888/samples/hello-world/.

If you then click on XML, you will get some XML output. If you instead click on HTML, you will see that you are taken to http://localhost:8888/samples/hello-world/hello.html. And the XML is rendered as HTML. If you instead click on XHTML, you will see that you are taken to http://localhost:8888/samples/hello-world/hello.xhtml. And the XML is rendered as XHTML. There are other links down the left-hand side of this page that enable you to get the XML rendered in other formats.

The XML is in the file:

C:\cocoon-2.1.7\build\webapp\samples\hello-world\content\hello.xml
The XSL files that do the transformations are in the directory:
C:\cocoon-2.1.7\build\webapp\samples\hello-world\style\xsl
For example, the file that does the transformation from XML to HTML is in the file:
C:\cocoon-2.1.7\build\webapp\samples\hello-world\style\xsl\page2html.xsl

So alter both the hello.xml and the page2html.xsl files and then revisit http://localhost:8888/samples/hello-world/hello.html. In hello.xml I altered first to 2nd, and in page2html.xsl I altered the h1 element to an h2 element.

When rendering the HTML, a CSS file is used. This is because page2html.xsl outputs a link element referring to a css file called main.css. The main.css file is in the directory:

C:\cocoon-2.1.7\build\webapp\resources\styles
Although this centre's an h1 element it does not centre an h2 element. So this is a change that will occur if you alter the h1 to an h2.

Note that there are no actual files called hello.html or hello.xhtml. Instead the system is configured so that if you visit a URL like http://localhost:8888/samples/hello-world/hello.html it has to take the file content\hello.xml and apply the transformation in the file xsl\page2html.xsl.

The file that controls all this is the file:

C:\cocoon-2.1.7\build\webapp\samples\hello-world\sitemap.xmap
If you look at this file, you will see the instructions that control what transformations should take place.