<?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="i18n" src="org.apache.cocoon.transformation.I18nTransformer">
        <catalogues default="other">
          <catalogue id="other" name="OtherMessages" location="messages"/>
          <catalogue id="forms" name="messages" location="resource://org/apache/cocoon/forms/system/i18n"/>
        </catalogues>
      </map:transformer>
    </map:transformers>
    
    <map:actions>
      <map:action name="make-form" src="org.apache.cocoon.forms.acting.MakeFormAction" logger="forms"/>
      <map:action name="init-form" src="org.apache.cocoon.forms.samples.InitForm1Action" logger="forms"/>
      <map:action name="handle-form-submit" src="org.apache.cocoon.forms.acting.HandleFormSubmitAction" logger="forms"/>
    </map:actions>
    
    <map:pipes default="caching">
      <map:pipe name="caching" src="org.apache.cocoon.components.pipeline.impl.CachingProcessingPipeline"/>
      <map:pipe name="noncaching" src="org.apache.cocoon.components.pipeline.impl.NonCachingProcessingPipeline"/>
    </map:pipes>
    
  </map:components>
  
  <map:views>
    <map:view name="content" from-label="content">
      <map:serialize type="xml"/>
    </map:view>
    
    <map:view from-label="content" name="pretty-content">
      <map:transform src="context://stylesheets/system/xml2html.xslt"/>
      <map:serialize type="html"/>
    </map:view>
    
    <map:view name="form" from-label="form">
      <map:serialize type="xml"/>
    </map:view>
    
    <map:view name="links" from-position="last">
      <map:serialize type="links"/>
    </map:view>
  </map:views>
  
  <map:resources>
    <!-- this will later become a virtual transformer -->
    <map:resource name="simple-page2html">
      <map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl">
        <map:parameter name="contextPath" value="{request:contextPath}"/>
        <map:parameter name="servletPath" value="{request:servletPath}"/>
        <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
        <map:parameter name="file" value="{file}"/>
        <map:parameter name="remove" value="{../0}"/>
      </map:transform> 
    </map:resource>
  </map:resources>
  
  <!-- indicates what flowscript to attach to this sitemap -->
  <map:flow language="javascript">
    <map:script src="flow/library.js"/>
  </map:flow>
  
  <map:pipelines>
    
    <map:pipeline type="caching">
      
      <map:match pattern="library/**">
        <map:read src="libraries/{1}"/>
      </map:match>
      
    </map:pipeline>
    <map:pipeline type="noncaching">
      
      <map:match pattern="">
        <map:generate src="index.xml"/>
        <map:serialize/>
      </map:match>
      
      
      
      <map:match pattern="*.continue">
        <map:call continuation="{1}"/>
      </map:match>
      
      <map:match pattern="*-display-pipeline">
        <!-- pipeline to show the form -->
        <map:generate type="jx" src="forms/{1}_template.xml"/>
        <map:transform type="forms"/>
        <map:transform type="i18n" label="form">
          <map:parameter name="locale" value="en-US"/>
        </map:transform>
        <map:call resource="simple-page2html">
          <map:parameter name="file" value="forms/{1}_template.xml"/>
        </map:call>
        <map:transform src="../resources/forms-samples-styling.xsl">
          <map:parameter name="resources-uri" value="{request:contextPath}/_cocoon/resources"/>
        </map:transform>
        <map:serialize/>
      </map:match>
      
      <map:match pattern="*-error-pipeline">
        <map:generate src="error.xml"/>
        <map:serialize/>
      </map:match>
      
      <map:match pattern="*-success-pipeline.jx">
        <map:generate type="jx" src="resources/result_jx.xml"/>
        <map:call resource="simple-page2html">
          <map:parameter name="file" value="resources/result_jx.xml"/>
        </map:call>
        <map:serialize type="xml"/>
      </map:match>
      
      <map:match pattern="resources/*/**">
        <map:read src="resource://org/apache/cocoon/{1}/resources/{2}"/>
      </map:match>
      
      
      
      <!--
         | Sample building a forms-form-gui editor in forms
         | Doubles as a showcase for class, new, struct, union widgets
         -->
      
      <!-- TODO: Fix edit-any-file security hole! -->
      <map:match pattern="*.flow">
        <map:call function="handleForm">
          <map:parameter name="function" value="show_{1}"/>
          <map:parameter name="form-definition" value="forms/{1}_model.xml"/>
          <map:parameter name="bindingURI" value="forms/{1}_binding.xml"/>
        </map:call>
      </map:match>
      
      
      <map:match pattern="*">
        <map:redirect-to uri="{1}/"/>
      </map:match>
      
      <map:match pattern="*/**">
        <map:mount src="{1}/" uri-prefix="{1}"/>
      </map:match>
      
    </map:pipeline>
  </map:pipelines>
  
</map:sitemap>
