<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<!-- CVS $Id: sitemap.xmap 474832 2006-11-14 15:56:43Z vgritsenko $ -->

<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">

  <!-- =========================== Components ================================ -->
  <map:components>
    <map:generators default="file">
      <!-- redefine the generators to remove their labels (otherwise aggregated parts also go through views) -->
      <map:generator name="file"
                     logger="sitemap.generator.file"
                     src="org.apache.cocoon.generation.FileGenerator"/>
      <map:generator name="serverpages"
                     logger="sitemap.generator.serverpages"
                     src="org.apache.cocoon.generation.ServerPagesGenerator"/>
    </map:generators>

    <map:transformers default="xslt">
      <!-- Configure i18n transformer -->
      <map:transformer name="i18n"
                       logger="sitemap.transformer.i18n"
                       src="org.apache.cocoon.transformation.I18nTransformer">
        <catalogues default="messages">
          <catalogue id="messages" name="messages" location="translations"/>
          <catalogue id="menu" name="menu" location="translations"/>
          <catalogue id="tiered" name="messages">
            <location>translations/tiered</location>
            <location>translations</location>
          </catalogue>
        </catalogues>
      </map:transformer>
    </map:transformers>

    <map:actions>
      <!-- LocaleAction is used to set/get current users locale. See Javadocs for details. -->
      <map:action name="locale" logger="sitemap.action.locale" src="org.apache.cocoon.acting.LocaleAction">
        <!-- Creates a new session if needed. Used with 'store-in-session' param -->
        <create-session>true</create-session>
        <!-- Stores locale information in session. A session should be created before, 
             otherwise 'create-session' should be true.
                -->
        <store-in-session>true</store-in-session>
        <!-- Stores locale information in request attributes -->
        <store-in-request>true</store-in-request>
        <!-- Stores locale information in a client cookie -->
        <store-in-cookie>false</store-in-cookie>
        <!-- Uncomment as needed to override defaults:
             <locale-attribute>locale</locale-attribute>
             <language-attribute>language</language-attribute>
             <country-attribute>country</country-attribute>
             <variant-attribute>variant</variant-attribute>
          -->
      </map:action>
    </map:actions>
  </map:components>

  <!-- =========================== Resources =============================== -->
  <map:resources>
    <!-- This resource is used to create a composite page from menu and content -->
    <map:resource name="composite">
      <map:aggregate element="root">
        <map:part src="cocoon:/menu/{../0}"/>
        <map:part src="cocoon:/content/{../0}" label="content"/>
      </map:aggregate>
      <map:transform src="simple2page.xsl">
        <map:parameter name="page" value="{../0}"/>
        <map:parameter name="locale" value="{../../locale}"/>
      </map:transform>
      <map:transform src="context://samples/common/style/xsl/html/complex-page2html.xsl">
        <map:parameter name="contextPath" value="{request:contextPath}"/>
      </map:transform>
      <map:serialize type="html"/>
    </map:resource>
  </map:resources>

  <!-- =========================== Views =================================== -->
  <map:views>
    <map:view name="content" from-label="content">
      <map:serialize type="xml"/>
    </map:view>

    <map:view name="pretty-content" from-label="content">
      <map:transform src="context://stylesheets/system/xml2html.xslt"/>
      <map:serialize type="html"/>
    </map:view>

    <map:view name="links" from-position="last">
      <map:serialize type="links"/>
    </map:view>
  </map:views>

  <!-- =========================== Pipelines ================================= -->
  <map:pipelines>
    <map:pipeline>
      <map:act type="locale">
        <!-- Locale aware content generation pipeline -->

        <!-- Default pipeline -->
        <map:match pattern="">
          <map:redirect-to uri="simple.xml"/>
        </map:match>

        <!-- Generate static output (simple.xml) -->
        <map:match pattern="*.xml">
          <map:call resource="composite"/>
        </map:match>

        <!-- Generate dynamic output (simple.xsp) -->
        <map:match pattern="*.xsp">
          <map:call resource="composite"/>
        </map:match>

        <!-- A helper matcher for static content translation and generation -->
        <map:match pattern="content/tiered.xml">
          <map:generate src="tiered.xml"/>
          <map:transform type="i18n">
        <map:parameter name="default-catalogue-id" value="tiered"/>
            <map:parameter name="locale" value="{../locale}"/>
          </map:transform>
          <map:serialize/>
        </map:match>

        <!-- A helper matcher for static content translation and generation -->
        <map:match pattern="content/*.xml">
          <map:generate src="{1}.xml"/>
          <map:transform type="i18n">
            <map:parameter name="locale" value="{../locale}"/>
          </map:transform>
          <map:serialize/>
        </map:match>

        <!-- A helper matcher for dynamic content translation and generation -->
        <map:match pattern="content/*.xsp">
          <map:generate type="serverpages" src="{1}.xsp"/>
          <map:transform type="i18n">
            <map:parameter name="locale" value="{../locale}"/>
          </map:transform>
          <map:serialize/>
        </map:match>

        <!-- Menu generation -->
        <map:match pattern="menu/*">
          <map:generate src="menu.xml"/>
          <map:transform type="i18n">
            <!-- Override default catalogue for this pipeline -->
            <map:parameter name="default-catalogue-id" value="menu"/>
            <map:parameter name="locale" value="{../locale}"/>
          </map:transform>
          <map:serialize/>
        </map:match>
      </map:act>

      <!-- Display this sitemap source -->
      <map:match pattern="sitemap.xmap">
        <map:generate src="sitemap.xmap"/>
        <map:transform src="context://stylesheets/system/xml2html.xslt"/>
        <map:serialize/>
      </map:match>

      <map:match pattern="*.css">
        <map:read src="{1}.css" mime-type="text/css"/>
      </map:match>

      <map:match pattern="images/*.gif">
        <map:read src="images/{1}.gif" mime-type="image/gif"/>
      </map:match>

    </map:pipeline>
  </map:pipelines>
</map:sitemap>
