The Sitemap |
The file sitemap.xmap is the Cocoon sitemap for the Bonebreaker site. I only explain the parts of the sitemap that are of special interest for this tutorial. Look at the Cocoon documentation for further information.
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:generators default="file"/>
<map:transformers default="xslt">
<map:transformer name="xslt"
src="org.apache.cocoon.transformation.TraxTransformer"/>
</map:transformers>
<map:readers default="resource"/>
<map:serializers default="html">
<map:serializer name="html" mime-type="text/html"
src="org.apache.cocoon.serialization.HTMLSerializer"/>
</map:serializers>
<map:matchers default="wildcard">
<map:matcher name="wildcard"
src="org.apache.cocoon.matching.WildcardURIMatcherFactory"/>
</map:matchers>
</map:components>
<map:pipelines>
<map:pipeline>
This matcher redirects the empty path to the homepage (page home.xml in the section "home")
<!-- homepage -->
<map:match pattern="">
<map:redirect-to session="false"
uri="bonebreaker/home/home.section"/>
</map:match>
These matchers create the standard pages and the section title pages.
The asterisks have the following meaning:
- {1} section
- {2} page file name
- {3} XSLT file to transform the page
The parameters:
- section: The currently selected section.
- toc-file: The XML file that contains the table of contents. The path starts with ".." because the current directory is the stylesheets directory where the XSLT files are located.
- request-url: The file that was requested. Used to label the currently selected menu item.
- css-stylesheet: The CSS stylesheet for the page.
- base-url: The base URL of the site. This is coded in a parameter so that the XSLT files can easily be reused for other sites. You may have to change the base URL for your own site.
<!-- pages -->
<map:match pattern="*/*.*">
Generation: Load the XML page
<map:generate src="documents/{1}/{2}.xml"/>
Transformation Step 1: Transform the XML page to an HTML fragment. The parameters are needed by the section.xsl stylesheet to display the local menu of the current section on the section title page.
<map:transform src="stylesheets/{3}.xsl">
<map:parameter name="section" value="{1}"/>
<map:parameter name="toc-file"
value="../documents/toc.xml"/>
<map:parameter name="base-url" value="/cocoon/bonebreaker"/>
</map:transform>
Transformation Step 2: Create the navigation menu and combine it with the actual page. The XSLT file menupage.xsl imports menu.xsl and creates the menu from toc.xml.
<map:transform src="stylesheets/menupage.xsl">
<map:parameter name="section" value="{1}"/>
<map:parameter name="request-url" value="{2}.{3}"/>
<map:parameter name="toc-file"
value="../documents/toc.xml"/>
<map:parameter name="css-stylesheet" value="default.css"/>
<map:parameter name="base-url" value="/cocoon/bonebreaker"/>
</map:transform>
Serialisation:
<map:serialize/>
</map:match>
This matcher reads the CSS stylesheet files.
<!-- css stylesheets -->
<map:match pattern="*.css">
<map:read src="css/{1}.css" mime-type="text/css"/>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>




