Appendix
Previous  Top 

This section contains the source of a .xml and .xsl file which you can use to test the most basic Cocoon functionality. Create the following files and copy them to a subdirectory of Cocoon, I will use xmltest:

test.xml:
<?xml version="1.0"?>
  <page>
    <title>XML and XSL become HTML</title>
    <greeting>Hello NETIKUS.NET</greeting>
  </page>
<?xml version="1.0"?>

test.xsl:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="page">
    <html>
      <head>
        <title><xsl:value-of select="title"/></title>
      </head>
      <body>
        <h1><xsl:value-of select="title"/></h1>
        <p><xsl:value-of select="greeting"/></p>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Then add the following lines (as explained in chapter 4.d) to sitemap.xmap,

<map:match pattern="xmltest/*.xml">
 <map:generate type="file" src="xmltest/{1}.xml">
 <map:transform type="xslt" src="xmltest/{1}.xsl">
 <map:serialize/>
</map:match>

restart Tomcat and Apache, and get yourself a cup of tea or coffee. Please note that we could have also written

 <map:transform type="xslt" src="xmltest/test.xsl">

in line three to map every .xml file in the xmltest subdirectory to test.xsl.


Please send comments to ingmar.koecher@netikus.net