<?xml version="1.0"?>
<!-- ===============================================
'faq' pipelines.  Implements source XML, body HTML and output PDF pipelines.

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

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

$Revision: 1.19 $
==================================================== -->


<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.cocoon.acting.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-v20a">
          <document-declaration public-id="-//APACHE//DTD FAQ V2.0a//EN" />
        </sourcetype>
      </map:action>
    </map:actions>

    <map:selectors default="browser">
      <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="resources/stylesheets/faqv10tofaqv11.xsl" />
            <map:transform src="resources/stylesheets/faq2document.xsl" />
          </map:when>
          <map:when test="faq-v11">
            <map:transform src="resources/stylesheets/faq2document.xsl" />
          </map:when>
          <map:when test="faq-v12">
            <map:transform src="resources/stylesheets/faq2document.xsl" />
          </map:when>
          <map:when test="faq-v20a">
            <map:transform src="resources/stylesheets/faqv20tofaqv12.xsl" />
            <map:transform src="resources/stylesheets/faq2document.xsl" />
          </map:when>
          <map:otherwise />
        </map:select>
      </map:act>
      <map:transform type="idgen" />
    </map:resource>

    <map:resource name="skinit">
      <map:transform src="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="path" value="{path}"/>
        <!-- Can set an alternative project skinconfig here 
        <map:parameter name="config-file" value="../../../../skinconf.xml"/>
        -->
      </map:transform>

      <map:serialize/>
    </map:resource>

  </map:resources>

  <map:pipelines>

    <map:pipeline>

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

      <!-- Special matcher for FAQ PDFs, so we can pass an extra
      'numbersections' param into document2fo.xsl -->
      <map:match pattern="**.pdf">
        <map:generate src="cocoon:/{1}.xml"/>
        <map:transform src="skins/{forrest:skin}/xslt/fo/document2fo.xsl">
          <map:parameter name="numbersections" value="false"/>
          <map:parameter name="ctxbasedir" value="{realpath:.}/"/>
          <map:parameter name="xmlbasedir" value="content/xdocs/{1}"/>
        </map:transform>
        <map:serialize type="fo2pdf"/>
      </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: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="content/xdocs/{0}" />
        <map:call resource="transform-to-document">
          <map:parameter name="src" value="content/xdocs/{0}" />
        </map:call>
        <map:serialize type="xml-document"/>
      </map:match>

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