<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
    <!-- =========================== Components ================================ -->
    <map:components>
        <map:generators default="xsp">
            <map:generator name="xsp" src="org.apache.cocoon.generation.ServerPagesGenerator" logger="sitemap.generator.serverpages" pool-max="32" pool-min="4" pool-grow="2"/>
            <map:generator name="directory" src="org.apache.cocoon.generation.DirectoryGenerator" logger="sitemap.generator.directory" label="content,data" pool-max="16" pool-min="2" pool-grow="2"/>
        </map:generators>
        <map:transformers default="xsl">
            <map:transformer name="xsl" src="org.apache.cocoon.transformation.TraxTransformer" logger="sitemap.transformer.xslt" pool-max="32" pool-min="8" pool-grow="2">
                <use-request-parameters>true</use-request-parameters>
                <xslt-processor-role>saxon</xslt-processor-role>
            </map:transformer>
            <!-- Removes the elements of any document passed to it based on element name/uri mappings as parameters -->
            <map:transformer name="elementStripper" src="fr.gouv.culture.sdx.sitemap.transformers.ElementFilter" logger="sitemap.transformer.elementStripper">
                <!-- list of element names and namspaces for which the sax events will be stripped-->
                <parameter name="user" value="http://www.culture.gouv.fr/ns/sdx/sdx"/>
                <parameter name="group" value="http://www.culture.gouv.fr/ns/sdx/sdx"/>
                <parameter name="parameters" value="http://www.culture.gouv.fr/ns/sdx/sdx"/>
                <parameter name="parameter" value="http://www.culture.gouv.fr/ns/sdx/sdx"/>
            </map:transformer>
            <map:transformer name="tagStripper" src="fr.gouv.culture.sdx.sitemap.transformers.TagFilter" logger="sitemap.transformer.tagStripper">
            <!-- list of tags and namspaces for which the sax events will be stripped-->
            <parameter name="dummyRoot" value="http://www.culture.gouv.fr/ns/oai/"/>
             <parameter name="document" value="http://www.culture.gouv.fr/ns/sdx/sdx"/>
            </map:transformer>
        </map:transformers>
        <map:readers default="resource">
            <map:reader name="resource" src="org.apache.cocoon.reading.ResourceReader" logger="sitemap.reader.resource" pool-max="32"/>
            <map:reader name="getatt" logger="sdx.sitemap.DocumentReader" src="fr.gouv.culture.sdx.sitemap.DocumentReader"/>
        </map:readers>
        <map:serializers default="html">
            <map:serializer name="html" mime-type="text/html" src="org.apache.cocoon.serialization.HTMLSerializer">
                <encoding>ISO-8859-1</encoding>
            </map:serializer>
            <map:serializer name="xml" mime-type="text/xml" src="org.apache.cocoon.serialization.XMLSerializer" pool-max="32" pool-min="16" pool-grow="4"/>
        </map:serializers>
        <map:actions default="superuser">
            <map:action name="superuser" logger="sdx.sitemap.SuperuserAction" src="fr.gouv.culture.sdx.sitemap.SuperuserAction"/>
            <map:action name="request" src="org.apache.cocoon.acting.RequestParamAction"/>
        </map:actions>
        <map:matchers default="wildcard">
            <map:matcher name="wildcard" src="org.apache.cocoon.matching.WildcardURIMatcher"/>
            <map:matcher name="request" logger="sitemap.matcher.request-parameter" src="org.apache.cocoon.matching.RequestParameterMatcher"/>
        </map:matchers>
    </map:components>
    <!-- =========================== Pipelines ================================= -->
    <map:pipelines>
        <map:pipeline id="normal">
			<!-- internal generation from admin folder to a list of open apps -->
			<map:match pattern="">
				<map:redirect-to uri="admin/welcome.xsp"/>
			</map:match>
			<!-- mount the sdx-admin sitemap -->
			<map:match pattern="admin**">
				<map:mount uri-prefix="admin" src="admin/sdx-admin.xmap" check-reload="yes"/>
			</map:match>
            <!-- api-url, could be used from every where to have the sdx:taglib fonctions -->
            <map:match pattern="api-url/getatt">
                <map:act type="request">
                    <map:parameter name="parameters" value="true"/>
                    <map:read type="getatt" src="{requestQuery}">
                        <map:parameter name="app" value="{app}"/>
                        <map:parameter name="base" value="{base}"/>
                        <map:parameter name="id" value="{id}"/>
                        <!-- id of the attached document, relative to a main document id -->
                        <map:parameter name="attid" value="{attid}"/>
                    </map:read>
                </map:act>
            </map:match>
            <map:match pattern="api-url/*">
                <map:generate type="xsp" src="api-url/{1}.xsp"/>
                <!-- map:transform src="api-url/api-url.xsl"/ -->
                <map:transform type="tagStripper"/>
                <map:transform type="elementStripper"/>
                <map:serialize type="xml"/>
            </map:match>
            <!-- oai  -->
            <map:match pattern="oai/harvest.xsp">
                <map:generate type="xsp" src="oai/harvest.xsp"/>
                <map:serialize type="xml"/>
            </map:match>
            <map:match pattern="oai/*/*/*">
                <map:generate type="xsp" src="api-url/get.xsp">
                    <map:parameter name="appbypath" value="{1}"/>
                    <map:parameter name="base" value="{2}"/>
                    <map:parameter name="id" value="{3}"/>
                </map:generate>
                <map:transform type="tagStripper"/>
                <map:serialize type="xml"/>
            </map:match>
            <map:match pattern="oai/*/*">
                <map:generate type="xsp" src="oai/oai.xsp">
                    <map:parameter name="appbypath" value="{1}"/>
                    <map:parameter name="base" value="{2}"/>
                 </map:generate>
                 <map:transform type="tagStripper"/>
                 <map:serialize type="xml"/>
            </map:match>
            <!-- static documentation -->
            <map:match pattern="documentation">
                <map:redirect-to uri="documentation/fr/index.html"/>
            </map:match>
            <map:match pattern="documentation/">
                <map:redirect-to uri="fr/index.html"/>
            </map:match>
            <map:match pattern="documentation/fr">
                <map:redirect-to uri="index.html"/>
            </map:match>
            <map:match pattern="documentation/en">
                <map:redirect-to uri="index.html"/>
            </map:match>
			<map:match pattern="**">
				<map:redirect-to uri="admin/"/>
			</map:match>
        </map:pipeline>
    </map:pipelines>
</map:sitemap>
