<?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.
-->
<!-- ===============================================
'book.xml' pipeline, which generates XML that becomes the menu.

Generates  :  Menulinks XML: Variant of site.xml that will become the menu for the current page.
Generates  :  Book HTML: A HTML menu for the current page.
Example URL:  http://localhost:8888/community/menulinks-index.html (menu links for community/index.html)
Example URL:  http://localhost:8888/community/book-index.html (menu for community/index.html)
Used by    :  **/menu-*.html in sitemap.xmap, 
Uses       :  content/xdocs/site.xml, or book.xml file if present.

See http://forrest.apache.org/docs/sitemap-ref.html#menu_generation_impl

$Revision: 1.2 $
==================================================== -->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  <map:components>
    <map:generators default="file"/>
    <map:serializers default="html"/>
    <map:transformers default="xslt">
      <map:transformer name="i18n" src="org.apache.cocoon.transformation.I18nTransformer">
        <catalogues default="menu">
          <catalogue id="menu" name="menu" location="{lm:project.translations}"/>
        </catalogues>
<!-- Commented out to verify your translations
        <untranslated-text>untranslated</untranslated-text> -->
        <cache-at-startup>true</cache-at-startup>
      </map:transformer>
    </map:transformers>
    <map:matchers default="wildcard"/>
    <map:selectors>
      <map:selector logger="sitemap.selector.config" name="config" src="org.apache.cocoon.selection.SimpleSelector" />
    </map:selectors>
  </map:components>
  <map:pipelines>
<!-- ============================================================ -->
<!-- SOURCE FORMATS                                               -->
<!-- ============================================================ -->
    <map:pipeline internal-only="false">
      <map:match pattern="abs-menulinks">
        <map:generate src="cocoon://site.navigation.links.xml"/>
        <map:transform src="{lm:transform.linkmap.linkmap-absolutized}" />
        <map:transform src="{lm:transform.linkmap.linkmap-normalizedtabs}" />
        <map:transform src="{lm:transform.xml.xml-normalizedhrefs}"/>
        <map:serialize type="xml"/>
      </map:match>
      <map:match pattern="**menulinks-*">
        <map:generate src="cocoon://site.navigation.links.xml"/>
        <map:transform src="{lm:transform.linkmap.linkmap-absolutized}" />
        <map:select type="config">
          <map:parameter name="value" value="{properties:forrest.menu-scheme}"/>
          <map:when test="tab_attributes">
            <map:transform src="{lm:transform.linkmap.linkmap-normalizedtabs}" />
            <map:transform src="{lm:transform.xml.xml-normalizedhrefs}"/>
            <map:transform src="{lm:transform.linkmap.linkmap-selectnode}">
              <map:parameter name="path" value="{1}{2}"/>
            </map:transform>
          </map:when>
          <map:when test="directories">
            <map:transform type="xpath">
              <map:parameter name="include" value="//*[@href='{1}']" />
            </map:transform>
          </map:when>
        </map:select>
        <map:transform src="{lm:transform.linkmap.linkmap-relativized}">
          <map:parameter name="path" value="{1}{2}" />
        </map:transform>
        <map:serialize type="xml" />
      </map:match>
    </map:pipeline>
<!-- ============================================================ -->
<!-- INTERMEDIATE FORMATS                                         -->
<!-- ============================================================ -->
    <map:pipeline>
      <map:match pattern="**book-*">
        <map:select type="exists">
          <map:when test="{lm:project.{1}book.xml}">
<!-- If a hand-created book.xml exists, use it -->
            <map:parameter name="url" value="{lm:project.{1}book.xml}" />
            <map:generate src="{lm:project.{1}book.xml}" />
          </map:when>
          <map:otherwise>
<!-- If no book.xml, generate it from the linkmap. -->
            <map:generate src="cocoon:/{1}menulinks-{2}" />
<!-- The above generates the subset of the linkmap relevant to our directory. -->
            <map:transform src="{lm:transform.site.book}" />
          </map:otherwise>
        </map:select>
        <map:select type="config">
          <map:parameter name="value" value="{properties:forrest.i18n}"/>
          <map:when test="true">
            <map:act type="locale">
              <map:transform src="{lm:transform.book.book-i18n}"/>
              <map:transform type="i18n">
                <map:parameter name="locale" value="{locale}"/>
              </map:transform>
            </map:act>
          </map:when>
        </map:select>
        <map:serialize type="xml"/>
      </map:match>
    </map:pipeline>
  </map:pipelines>
</map:sitemap>
