<?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.
-->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  <map:components>
    <map:transformers default="xslt">
      <map:transformer name="lexer" 
	                     src="org.apache.cocoon.transformation.LexicalTransformer" 
	                     logger="sitemap.transformer.lexer">
        <parameter name="localizable" value="true"/>
      </map:transformer>
      <map:transformer name="parser" 
	                     src="org.apache.cocoon.transformation.ParserTransformer" 
	                     logger="sitemap.transformer.parser">
        <parameter name="flatten" value="true"/>
        <parameter name="recovery" value="true"/>
        <parameter name="localizable" value="true"/>
      </map:transformer>
    </map:transformers>
  </map:components>
  <map:resources>
    <map:resource name="file-resolver">
      <map:select type="exists">
        <map:when test="{lm:project.{uri}.moinwiki}">
          <map:match type="regexp" pattern="^(.*?)([^/]*).xml$">
            <map:generate type="text2xml" src="{lm:project.{1}{2}.moinwiki}" />
            <map:transform type="lexer"   src="cocoon:/moinwiki.xlex"/>
            <map:transform type="parser"  src="cocoon:/moinwiki.xgrm"/>
            <map:transform type="xsltc" 
              src="{lm:wiki.transform.moinwiki.xdoc}">
              <map:parameter name="name" value="{2}" />
              <map:parameter name="spaceless-filenames" value="true"/>
            </map:transform>
            <map:serialize type="xml-document"/>
          </map:match>
        </map:when>
        <map:when test="{lm:project.{uri}.jspwiki}">
          <map:match type="regexp" pattern="^(.*?)([^/]*).xml$">
            <map:generate type="text2xml" src="{lm:project.{1}{2}.jspwiki}" />
            <map:transform type="lexer"   src="cocoon:/wiki.xlex"/>
            <map:transform type="parser"  src="cocoon:/wiki.xgrm"/>
            <map:transform type="xsltc" 
              src="{lm:wiki.transform.wiki.xdoc}">
              <map:parameter name="name" value="{2}" />
              <map:parameter name="spaceless-filenames" value="true"/>
            </map:transform>
            <map:serialize type="xml-document"/>
          </map:match>
        </map:when>
        <map:when test="{lm:project.{uri}.cwiki}">
          <map:match type="regexp" pattern="^(.*?)([^/]*).xml$">
            <map:generate type="text2xml" src="{lm:project.{1}{2}.cwiki}" />
            <map:transform type="lexer"   src="cocoon:/wiki.xlex"/>
            <map:transform type="parser"  src="cocoon:/wiki.xgrm"/>
            <map:transform type="xsltc" 
              src="{lm:wiki.transform.wiki.xdoc}">
              <map:parameter name="name" value="{2}" />
              <map:parameter name="spaceless-filenames" value="true"/>
            </map:transform>
            <map:serialize type="xml-document"/>
          </map:match>
        </map:when>
        <!-- Google Code Wiki Markup -->
        <map:when test="{lm:project.{uri}.wiki}">
          <map:match type="regexp" pattern="^(.*?)([^/]*).xml$">
            <map:generate type="text2xml" src="{lm:project.{1}{2}.wiki}" />
            <map:transform type="lexer"   src="cocoon:/googlewiki.xlex"/>
            <map:transform type="parser"  src="cocoon:/googlewiki.xgrm"/>
            <map:transform type="xsltc" 
              src="{lm:wiki.transform.googlewiki.xdoc}">
              <map:parameter name="name" value="{2}" />
              <map:parameter name="spaceless-filenames" value="true"/>
            </map:transform>
            <map:serialize type="xml-document"/>
          </map:match>
        </map:when>
      </map:select>
    </map:resource>
  </map:resources>
  <map:pipelines>
    <map:pipeline internal="true">
      <map:match pattern="**.xml">
        <map:call resource="file-resolver">
          <map:parameter name="uri" value="{1}"/>
        </map:call>
      </map:match>
    </map:pipeline>
    <map:pipeline type="caching" internal-only="true">
      <map:match pattern="*.xlex">
        <map:select type="exists">
          <map:when test="{lm:wiki.grammar.{1}.xlex}">
            <map:read src="{lm:wiki.grammar.{1}.xlex}"/>
          </map:when>
          <map:otherwise>
            <map:generate  type="text2xml"   src="{lm:wiki.grammar.{1}.grm}"/>
            <map:transform type="lexer"  src="{lm:wiki.grammar.grm.xlex}"/>
            <map:transform type="parser" src="{lm:wiki.grammar.grm.xgrm}"/>
            <map:transform               src="{lm:wiki.transform.text4regex}"/>
            <map:transform type="lexer"  src="{lm:wiki.grammar.regex.xlex}"/>
            <map:transform type="parser" src="{lm:wiki.grammar.regex.xgrm}"/>
            <map:transform               src="{lm:wiki.transform.grm.xlex}"/>
            <map:serialize type="xml"/>
          </map:otherwise>
        </map:select>
      </map:match>
      <map:match pattern="*.xgrm">
        <map:select type="exists">
          <map:when test="{lm:wiki.grammar.{1}.xgrm}">
            <map:read src="{lm:wiki.grammar.{1}.xgrm}"/>
          </map:when>
          <map:otherwise>
            <map:generate  type="text2xml"   src="{lm:wiki.grammar.{1}.grm}"/>
            <map:transform type="lexer"  src="{lm:wiki.grammar.grm.xlex}"/>
            <map:transform type="parser" src="{lm:wiki.grammar.grm.xgrm}"/>
            <map:transform               src="{lm:wiki.transform.text4regex}"/>
            <map:transform type="lexer"  src="{lm:wiki.grammar.regex.xlex}"/>
            <map:transform type="parser" src="{lm:wiki.grammar.regex.xgrm}"/>
            <map:transform               src="{lm:wiki.transform.grm.xgrm}"/>
            <map:serialize type="xml"/>
          </map:otherwise>
        </map:select>
      </map:match>
      <map:match pattern="*.xegrm">
        <map:select type="exists">
          <map:when test="{lm:wiki.grammar.{1}.xegrm}">
            <map:read src="{lm:wiki.grammar.{1}.xegrm}"/>
          </map:when>
          <map:otherwise>
            <map:generate  type="text2xml"   src="{lm:wiki.grammar.{1}.egrm}"/>
            <map:transform type="extparser" src="{lm:wiki.grammar.egrm.xegrm}"/>
            <map:transform               src="{lm:wiki.transform.egrm.xegrm}"/>
            <map:serialize type="xml"/>
          </map:otherwise>
        </map:select>
      </map:match>
    </map:pipeline>
  </map:pipelines>
</map:sitemap>
