<?xml version="1.0"?>
<!-- ===============================================
Pipelines defining all Source XML types Forrest can handle.
Converts from arbitrary formats to standard Forrest doc-v12 XML.

First, checks if *.cwiki or *.ihtml exists, and uses them if present.
Otherwise, the default *.xml handling is used.  The XML's DTD type is
discovered using the SourceTypeAction, and an appropriate transformation
applied.  Thus to add new XML types, just define a new <sourcetype>
and an appropriate <map:when> handler.

Generates  :  Source XML, Body HTML for *.ehtml
Example URL:  http://localhost:8888/index.xml
Used by    :  *.html and *.pdf pipelines in sitemap.xmap
Uses       :  content/xdocs/**.xml

$Revision: 1.30.2.2 $
==================================================== -->

<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  <map:components>
  <!-- FIXME (JJP): This should not be here. Should be define on sitemap -->
  <map:generators default="file">


      <map:generator name="html"      src="org.apache.cocoon.generation.HTMLGenerator">
        <jtidy-config>jtidy.properties</jtidy-config>
      </map:generator>
      <map:generator name="text2xml" src="org.apache.cocoon.generation.TextGenerator" />
    </map:generators>
    <map:serializers default="html"/>
    <map:matchers default="wildcard"/>

    <map:transformers default="xslt">
      <map:transformer name="lexer" src="org.apache.cocoon.transformation.LexicalTransformer" logger="sitemap.transformer.lexer"/>
      <map:transformer name="parser" src="org.apache.cocoon.transformation.ParserTransformer" logger="sitemap.transformer.parser">
        <parameter name="flatten" value="true"/>
        <parameter name="ignoring" value="true"/>
      </map:transformer>
    </map:transformers>



    <map:actions>
      <map:action logger="sitemap.action.sourcetype" name="sourcetype" src="org.apache.cocoon.acting.sourcetype.SourceTypeAction">
        <sourcetype name="document-v10">
          <document-declaration public-id="-//APACHE//DTD Documentation V1.0//EN" />
        </sourcetype>
        <sourcetype name="howto-v10">
          <document-declaration public-id="-//APACHE//DTD How-to V1.0//EN" />
        </sourcetype>
        <sourcetype name="todo-v10">
          <document-declaration public-id="-//APACHE//DTD Todo V1.0//EN" />
        </sourcetype>
        <sourcetype name="changes-v10">
          <document-declaration public-id="-//APACHE//DTD Changes V1.0//EN" />
        </sourcetype>
        <sourcetype name="document-v11">
          <document-declaration public-id="-//APACHE//DTD Documentation V1.1//EN" />
        </sourcetype>
        <sourcetype name="howto-v11">
          <document-declaration public-id="-//APACHE//DTD How-to V1.1//EN" />
        </sourcetype>
        <sourcetype name="todo-v11">
          <document-declaration public-id="-//APACHE//DTD Todo V1.1//EN" />
        </sourcetype>
        <sourcetype name="changes-v11">
          <document-declaration public-id="-//APACHE//DTD Changes V1.1//EN" />
        </sourcetype>
        <sourcetype name="todo-v12">
          <document-declaration public-id="-//APACHE//DTD Todo V1.2//EN" />
        </sourcetype>
        <sourcetype name="changes-v12">
          <document-declaration public-id="-//APACHE//DTD Changes V1.2//EN" />
        </sourcetype>
        <sourcetype name="howto-v12">
          <document-declaration public-id="-//APACHE//DTD How-to V1.2//EN" />
        </sourcetype>
        <sourcetype name="document-v20a">
          <document-declaration public-id="-//APACHE//DTD Documentation V2.0a//EN" />
        </sourcetype>
        <sourcetype name="docbook-v4.2">
          <document-declaration public-id="-//OASIS//DTD DocBook XML V4.2//EN" />
        </sourcetype>
        <sourcetype name="sdocbook-v1.0">
          <document-declaration public-id="-//OASIS//DTD Simplified DocBook XML V1.0//EN" />
        </sourcetype>
      </map:action>
    </map:actions>
    <map:selectors default="parameter">
      <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="document-v10">
          <!-- FIXME (JJP):  This should use the v12 now-->
            <map:transform src="resources/stylesheets/docv10todocv11.xsl" />
          </map:when>

          <map:when test="document-v20a">
            <map:transform src="resources/stylesheets/docv20todocv12.xsl" />
          </map:when>

          <map:when test="howto-v10">
            <map:transform src="resources/stylesheets/howto2document.xsl" />
          </map:when>

          <map:when test="howto-v11">
            <map:transform src="resources/stylesheets/howto2document.xsl" />
          </map:when>
          <map:when test="howto-v12">
            <map:transform src="resources/stylesheets/howto2document.xsl" />
          </map:when>

          <map:when test="todo-v10">
            <map:transform src="resources/stylesheets/todo2document.xsl" />
          </map:when>

          <map:when test="todo-v11">
            <map:transform src="resources/stylesheets/todo2document.xsl" />
          </map:when>

          <map:when test="todo-v12">
            <map:transform src="resources/stylesheets/todo2document.xsl" />
          </map:when>

          <map:when test="changes-v10">
            <map:transform src="resources/stylesheets/changesv10tochangesv11.xsl" />
            <map:transform src="resources/stylesheets/changes2document.xsl" />
          </map:when>

          <map:when test="changes-v11">
            <map:transform src="resources/stylesheets/changes2document.xsl" />
          </map:when>

          <map:when test="changes-v12">
            <map:transform src="resources/stylesheets/changes2document.xsl" />
          </map:when>

          <map:when test="docbook-v4.2">
            <map:transform src="resources/stylesheets/docbook2document.xsl" />
          </map:when>

          <map:when test="sdocbook-v1.0">
            <map:transform src="resources/stylesheets/docbook2document.xsl" />
          </map:when>

          <map:otherwise />
        </map:select>
      </map:act>
    </map:resource>
  </map:resources>

  <map:pipelines>
    <map:pipeline>

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

      <map:match pattern="**body-*.html">
        <map:select type="exists">
          <map:when test="content/xdocs/{1}{2}.ehtml">
            <map:generate src="content/xdocs/{1}{2}.ehtml" />
            <map:transform src="resources/stylesheets/html2htmlbody.xsl" />
            <map:serialize type="xml" />
          </map:when>
        </map:select>
      </map:match>

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

      <map:match pattern="**.xml">

        <map:select type="exists">
          
          <map:when test="content/xdocs/{1}.ihtml">
            <map:generate src="content/xdocs/{1}.ihtml" type="html" />
            <map:transform src="resources/stylesheets/html2document.xsl" />
            <map:transform type="idgen" />
            <map:serialize type="xml-document"/>
          </map:when>

          <map:when test="content/xdocs/{1}.cwiki">
            <map:match type="regexp" pattern="^(.*?)([^/]*).xml$">
              <map:generate type="text2xml" src="content/xdocs/{1}{2}.cwiki" />
              <map:transform type="lexer"   src="resources/grammars/wiki.xlex"/>
              <map:transform type="parser"  src="resources/grammars/wiki.xgrm"/>
              <!--  Dynamically generated equivalents.  Matchers need to be added to
              the root sitemap for this to work.
              <map:transform type="lexer"   src="cocoon:/wiki.xlex"/>
              <map:transform type="parser"  src="cocoon:/wiki.xgrm"/>
              -->
              <map:transform src="resources/stylesheets/wiki2document.xsl">
                <map:parameter name="name" value="{2}" />
              </map:transform>
              <map:serialize type="xml-document"/>
            </map:match>
          </map:when>

          <map:when test="content/xdocs/{1}.txt">
            <map:match type="regexp" pattern="^(.*?)([^/]*).xml$">
              <map:generate type="text2xml" src="content/xdocs/{1}{2}.txt" />
              <map:transform src="resources/stylesheets/text2document.xsl">
                <map:parameter name="filename" value="{2}" />
              </map:transform>
              <map:serialize type="xml-document"/>
            </map:match>
          </map:when>

          <map:otherwise>
            <map:generate src="content/xdocs/{1}.xml" />
            <map:call resource="transform-to-document">
              <map:parameter name="src" value="content/xdocs/{1}.xml" />
            </map:call>
            <map:serialize type="xml-document"/>
          </map:otherwise>

        </map:select>

      </map:match>


      <!--
      These pipelines dynamically generate the wiki.{xlex,xgrm} files used in
      the *.cwiki pipeline.  They are not used by default to avoid the overhead.
      <map:match pattern="*.xlex">
        <map:generate                src="resources/grammars/{1}.grm"/>
        <map:transform type="lexer"  src="resources/grammars/grm.xlex"/>
        <map:transform type="parser" src="resources/grammars/grm.xgrm"/>
        <map:transform               src="resources/grammars/text4regex.xsl"/>
        <map:transform type="lexer"  src="resources/grammars/regex.xlex"/>
        <map:transform type="parser" src="resources/grammars/regex.xgrm"/>
        <map:transform               src="resources/grammars/grm2xlex.xsl"/>
        <map:serialize type="xml"/>
      </map:match>

      <map:match pattern="*.xgrm">
        <map:generate                src="resources/grammars/{1}.grm"/>
        <map:transform type="lexer"  src="resources/grammars/grm.xlex"/>
        <map:transform type="parser" src="resources/grammars/grm.xgrm"/>
        <map:transform               src="resources/grammars/text4regex.xsl"/>
        <map:transform type="lexer"  src="resources/grammars/regex.xlex"/>
        <map:transform type="parser" src="resources/grammars/regex.xgrm"/>
        <map:transform               src="resources/grammars/grm2xgrm.xsl"/>
        <map:serialize type="xml"/>
      </map:match>
      -->

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