<?xml version="1.0"?>
<!-- ===============================================
'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://xml.apache.org/forrest/sitemap-ref.html#menu_xml_generation

$Revision: 1.9 $
==================================================== -->

<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:matchers default="wildcard"/>
    <map:selectors default="browser">
      <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="content/xdocs/site.xml" />
        <map:transform src="resources/stylesheets/absolutize-linkmap.xsl" />
        <map:transform src="resources/stylesheets/site2site-normalizetabs.xsl" />
        <map:serialize type="xml"/>
      </map:match>

      <map:match pattern="**menulinks-*">
        <map:generate src="content/xdocs/site.xml" />
        <map:transform src="resources/stylesheets/absolutize-linkmap.xsl" />

        <map:select type="config">
          <map:parameter name="value" value="{defaults:menu-scheme}"/>

          <map:when test="tab_attributes">
            <map:transform src="resources/stylesheets/site2site-normalizetabs.xsl" />
            <map:transform src="resources/stylesheets/site2site-selectnode.xsl">
              <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="resources/stylesheets/relativize-linkmap.xsl">
          <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="content/xdocs/{1}book.xml">
            <!-- If a hand-created book.xml exists, use it -->
            <map:parameter name="url" value="content/xdocs/{1}book.xml" />
            <map:generate src="content/xdocs/{1}book.xml" />
            <map:serialize type="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="resources/stylesheets/site2book.xsl" />
            <map:serialize type="xml"/>
          </map:otherwise>

        </map:select>

      </map:match>

    </map:pipeline>


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