<?xml version="1.0"?>
<!--
  Copyright 2002-2004 The Apache Software Foundation or its licensors,
  as applicable.

  Licensed 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.
-->
<!-- ===============================================
'faq' pipelines.  Implements source XML, body HTML pipelines.

Handles different FAQ DTD versions by sniffing the DOCTYPE, and
applying an appropriate transformation.

Generates  :  Source XML, body HTML
Example URL:  http://localhost:8888/faq.xml       # Source XML for FAQ
Example URL:  http://localhost:8888/body-faq.html # Body HTML for FAQ
Used by    :  sitemap.xmap, which binds these generic pipelines to URLs.
Uses       :  content/xdocs/**.xml, depending on URL binding.

$Revision: 1.5 $
==================================================== -->


<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:actions>
      <map:action logger="sitemap.action.sourcetype" name="sourcetype" src="org.apache.forrest.sourcetype.SourceTypeAction">
        <sourcetype name="faq-v10">
          <document-declaration public-id="-//APACHE//DTD FAQ V1.0//EN" />
        </sourcetype>
        <sourcetype name="faq-v11">
          <document-declaration public-id="-//APACHE//DTD FAQ V1.1//EN" />
        </sourcetype>
        <sourcetype name="faq-v12">
          <document-declaration public-id="-//APACHE//DTD FAQ V1.2//EN" />
        </sourcetype>
        <sourcetype name="faq-v13">
          <document-declaration public-id="-//APACHE//DTD FAQ V1.3//EN" />
        </sourcetype>
        <sourcetype name="faq-v20a">
          <document-declaration public-id="-//APACHE//DTD FAQ V2.0a//EN" />
        </sourcetype>
        <sourcetype name="faq-v20">
          <document-declaration public-id="-//APACHE//DTD FAQ V2.0//EN" />
        </sourcetype>
      </map:action>
    </map:actions>

    <map:selectors>
      <map:selector logger="sitemap.selector.parameter" name="parameter" src="org.apache.cocoon.selection.ParameterSelector" />
    </map:selectors>
  </map:components>

  <map:resources>
    <map:resource name="transform-to-document">
      <map:act type="sourcetype" src="{src}">
        <map:select type="parameter">
          <map:parameter name="parameter-selector-test" value="{sourcetype}" />
          <map:when test="faq-v10">
            <map:transform src="{forrest:stylesheets}/faqv10tofaqv11.xsl" />
            <map:transform src="{forrest:stylesheets}/faq2document.xsl" />
          </map:when>
          <map:when test="faq-v11">
            <map:transform src="{forrest:stylesheets}/faq2document.xsl" />
          </map:when>
          <map:when test="faq-v12">
            <map:transform src="{forrest:stylesheets}/faq2document.xsl" />
          </map:when>
          <map:when test="faq-v13">
            <map:transform src="{forrest:stylesheets}/faq2document.xsl" />
          </map:when>
          <map:when test="faq-v20a">
            <map:transform src="{forrest:stylesheets}/faqv20tofaqv12.xsl" />
            <map:transform src="{forrest:stylesheets}/faq2document.xsl" />
          </map:when>
          <map:when test="faq-v20">
            <map:transform src="{forrest:stylesheets}/faqv20tofaqv13.xsl" />
            <map:transform src="{forrest:stylesheets}/faq2document.xsl" />
          </map:when>
          <map:otherwise />
        </map:select>
      </map:act>
      <map:transform type="idgen" />
    </map:resource>

    <map:resource name="skinit">
        <map:select type="exists">
          <map:when test="{project:skins-dir}{forrest:skin}/xslt/html/{type}.xsl">
            <map:transform src="{project:skins-dir}{forrest:skin}/xslt/html/{type}.xsl">
              <map:parameter name="notoc" value="{notoc}"/>
              <!-- For backwards-compat with 0.2 - 0.4 skins -->
              <map:parameter name="isfaq" value="{notoc}"/>
              <map:parameter name="nopdf" value="{nopdf}"/>
              <map:parameter name="path" value="{path}"/>
              <map:parameter name="config-file" value="{project:skinconf}"/>
            </map:transform>
          </map:when>
          <map:otherwise>
            <map:transform src="{forrest:context}/skins/{forrest:skin}/xslt/html/{type}.xsl">
              <map:parameter name="notoc" value="{notoc}"/>
              <!-- For backwards-compat with 0.2 - 0.4 skins -->
              <map:parameter name="isfaq" value="{notoc}"/>
              <map:parameter name="nopdf" value="{nopdf}"/>
              <map:parameter name="path" value="{path}"/>
              <map:parameter name="config-file" value="{project:skinconf}"/>
            </map:transform>
          </map:otherwise>
        </map:select>
      <map:serialize/>
    </map:resource>

  </map:resources>


  <map:pipelines>
      <map:pipeline internal-only="false">
         <map:match pattern="skinconf.xml">
           <map:generate src="{project:skinconf}" />
           <map:transform src="{forrest:stylesheets}/upgrade-skinconf.xsl"/>
           <map:select type="exists">
             <map:when test="{project:skins-dir}{forrest:skin}/skinconf.xsl">
               <map:transform src="{project:skins-dir}{forrest:skin}/skinconf.xsl"/>
             </map:when>
           </map:select>
           <map:select type="exists">
             <map:when test="{forrest:context}/skins/{forrest:skin}/skinconf.xsl">
               <map:transform src="{forrest:context}/skins/{forrest:skin}/skinconf.xsl"/>
             </map:when>
           </map:select>
           <map:transform src="{forrest:context}/skins/common/skinconf.xsl"/>
           <map:transform type="skinconf"/>
           <map:serialize type="xml" />
         </map:match>
       </map:pipeline>
    <map:pipeline>

      <!-- ============================================================ -->
      <!-- OUTPUT FORMATS                                               -->
      <!-- ============================================================ -->

      <!-- Special matcher for FAQ PDFs, so we can pass an extra
      'numbersections' param into document2fo.xsl -->
      <map:match pattern="**.fo">
        <map:aggregate element="site">
          <map:part src="cocoon:/skinconf.xml"/>
          <map:part src="cocoon:/{1}.xml"/>
        </map:aggregate>
        <map:transform type="xinclude"/>
        <map:transform type="linkrewriter" src="cocoon://{1}linkmap-{2}.pdf"/>
        <map:transform src="resources/stylesheets/declare-broken-site-links.xsl" />
        <map:select type="exists">
          <map:when test="{project:skins-dir}{forrest:skin}/xslt/fo/document2fo.xsl">
            <map:transform src="{project:skins-dir}{forrest:skin}/xslt/fo/document2fo.xsl">
               <map:parameter name="numbersections" value="false"/>
              <map:parameter name="imagesdir" value="{project:resources.images}/"/>
              <map:parameter name="xmlbasedir" value="{project:content.xdocs}{1}"/>
            </map:transform>
          </map:when>
          <map:when test="{forrest:context}/skins/{forrest:skin}/xslt/fo/document2fo.xsl">
            <map:transform src="{forrest:context}/skins/{forrest:skin}/xslt/fo/document2fo.xsl">
              <map:parameter name="numbersections" value="false"/>
              <map:parameter name="imagesdir" value="{project:resources.images}/"/>
              <map:parameter name="xmlbasedir" value="{project:content.xdocs}{1}"/>
            </map:transform>
          </map:when>
          <map:otherwise>
            <map:transform src="{forrest:context}/skins/common/xslt/fo/document2fo.xsl">
              <map:parameter name="numbersections" value="false"/>
              <map:parameter name="imagesdir" value="{project:resources.images}/"/>
              <map:parameter name="xmlbasedir" value="{project:content.xdocs}{1}"/>
            </map:transform>
          </map:otherwise>
        </map:select>
        <map:serialize type="xml"/>
      </map:match>

      <!-- ============================================================ -->
      <!-- INTERMEDIATE FORMATS                                         -->
      <!-- ============================================================ -->

      <!--Unfortunately we need to override all the document2html stuff too,
      since notoc must be set to true. -->
      <map:match pattern="**body-*.html">
        <map:generate src="cocoon:/{1}{2}.xml"/>
        <map:transform type="xinclude"/>
        <map:transform type="linkrewriter" src="cocoon://{1}linkmap-{2}.html"/>
        <map:transform src="resources/stylesheets/declare-broken-site-links.xsl" />
        <map:call resource="skinit">
          <map:parameter name="type" value="document2html"/>
          <map:parameter name="path" value="/{1}{2}.html"/>
          <map:parameter name="notoc" value="true"/>
        </map:call>
      </map:match>


      <!-- ============================================================ -->
      <!-- SOURCE FORMATS                                               -->
      <!-- ============================================================ -->

      <map:match pattern="**.xml">
        <map:generate type="file" src="{project:content.xdocs}{0}" />
        <map:call resource="transform-to-document">
          <map:parameter name="src" value="{project:content.xdocs}{0}" />
        </map:call>
        <map:serialize type="xml"/>
      </map:match>

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