<?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.
-->

<!-- main sitemap for supersonic tour of Cocoon -->

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

    <map:resources>
        <map:resource id="html" name="html">
            <map:transform src="intro/presentation/code2html.xsl"/>
            <map:transform src="intro/presentation/page2html.xsl"/>
            <map:serialize type="html"/>
        </map:resource>
    </map:resources>

    <map:pipelines>

        <map:pipeline>

            <!-- default page = front page -->
            <map:match pattern="">
                <map:redirect-to uri="intro/docs/index.html"/>
            </map:match>

            <!-- process docs transformation here -->
            <map:match pattern="**/docs/*.html">
                <map:aggregate element="toc-and-content">
                    <map:part src="{1}/docs/{2}.xml"/>
                    <map:part src="intro/docs/toc.xml"/>
                </map:aggregate>
                <map:transform src="intro/presentation/insert-toc.xsl">
                    <map:parameter name="basePath" value="../../"/>
                    <map:parameter name="currentPath" value="{1}/docs/"/>
                    <map:parameter name="currentPage" value="{1}/docs/{2}"/>
                </map:transform>
                <map:transform type="cinclude"/>
                <map:call resource="html"/>
            </map:match>

            <!-- aggreate everything in a single document for printing -->
            <map:match pattern="print/supersonic-tour.html">
                <map:generate src="intro/docs/toc.xml"/>
                <map:transform src="intro/presentation/toc-to-cinclude.xsl"/>

                <!-- need two cinclude as the pages themselves include stuff -->
                <map:transform type="cinclude"/>
                <map:transform type="cinclude"/>
                <map:call resource="html"/>
            </map:match>

            <!-- dump what's inside the page element -->
            <map:match pattern="page-content/**">
                <map:generate src="{1}"/>
                <map:transform src="intro/presentation/page-content.xsl"/>
                <map:serialize type="xml"/>
            </map:match>

            <!-- dump parts of XML documents for documentation -->
            <map:match pattern="xml-element/**/*">
                <map:generate src="{1}"/>
                <map:transform src="intro/presentation/select-id.xsl">
                    <map:parameter name="idToSelect" value="{2}"/>
                </map:transform>
                <map:serialize type="xml"/>
            </map:match>

            <!-- dump text files for documentation -->
            <map:match pattern="text-file/**/*">
                <map:generate type="slop" src="{1}/{2}"/>
                <map:transform src="intro/presentation/format-text-file.xsl">
                    <map:parameter name="filename" value="{2}"/>
                </map:transform>
                <map:serialize type="xml"/>
            </map:match>

            <!-- serve main CSS file from anywhere -->
            <map:match pattern="**/tour.css">
                <map:read src="intro/presentation/tour.css" mime-type="text/css"/>
            </map:match>

            <!-- mount everything else -->
            <map:match pattern="*/**">
                <map:mount check-reload="yes" src="{1}/" uri-prefix="{1}"/>
            </map:match>

        </map:pipeline>

    </map:pipelines>

</map:sitemap>
