<?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.
-->
<!-- ===============================================
'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="{lm:transform.faqv10.faqv11}" />
            <map:transform src="{lm:transform.faq.document}" />
          </map:when>
          <map:when test="faq-v11">
            <map:transform src="{lm:transform.faq.document}" />
          </map:when>
          <map:when test="faq-v12">
            <map:transform src="{lm:transform.faq.document}" />
          </map:when>
          <map:when test="faq-v13">
            <map:transform src="{lm:transform.faq.document}" />
          </map:when>
          <map:when test="faq-v20a">
            <map:transform src="{lm:transform.faqv20.faqv12}" />
            <map:transform src="{lm:transform.faq.document}" />
          </map:when>
          <map:when test="faq-v20">
            <map:transform src="{lm:transform.faqv20.faqv13}" />
            <map:transform src="{lm:transform.faq.document}" />
          </map:when>
          <map:otherwise />
        </map:select>
      </map:act>
      <map:transform type="idgen" />
    </map:resource>
    <map:resource name="skinit">
      <map:transform src="{lm:{type}}">
        <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="{lm:project.skinconf}"/>
      </map:transform>
      <map:serialize/>
    </map:resource>
  </map:resources>
  <map:pipelines>
    <map:pipeline internal-only="false">
      <map:match pattern="skinconf.xml">
        <map:generate src="{lm:project.skinconf}" />
        <map:transform src="{lm:transform.old-skinconf.new-skinconf}"/>
        <map:select type="exists">
          <map:when test="{lm:project-skinconf.xsl}">
            <map:transform src="{lm:project-skinconf.xsl}"/>
          </map:when>
        </map:select>
        <map:select type="exists">
          <map:when test="{lm:forrest-skinconf.xsl}">
            <map:transform src="{lm:forrest-skinconf.xsl}"/>
          </map:when>
        </map:select>
        <map:transform src="{lm: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 document-to-fo.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="{lm:transform.html.broken-links}" />
        <map:transform src="{lm:transform.document.fo}">
          <map:parameter name="numbersections" value="false"/>
          <map:parameter name="imagesdir" value="{properties:resources.images}/"/>
          <map:parameter name="xmlbasedir" value="{properties:content.xdocs}{1}"/>
        </map:transform>
        <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="{lm:transform.html.broken-links}" />
        <map:call resource="skinit">
          <map:parameter name="type" value="transform.xdoc.html"/>
          <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="{lm:project.{0}}" />
        <map:call resource="transform-to-document">
          <map:parameter name="src" value="{lm:project.{0}}" />
        </map:call>
        <map:serialize type="xml"/>
      </map:match>
    </map:pipeline>
  </map:pipelines>
</map:sitemap>
