<?xml version="1.0" encoding="UTF-8"?>
<!--

    The contents of this file are subject to the license and copyright
    detailed in the LICENSE and NOTICE files at the root of the source
    tree and available online at

    http://www.dspace.org/license/

-->

<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
	
	<map:components>
		
		<map:generators default="aspect">
			<!--
					The AspectGenerator provides the basic mechanism for chaining aspects 
					together. All Aspect pipelines must begin with the AspectGenerator so 
					that an internal request can be generated for the next Aspect in the
					chain. 
					-->
			<map:generator name="aspect" src="org.dspace.app.xmlui.cocoon.AspectGenerator"/>
		</map:generators>
		
		<map:matchers default="wildcard">
			<!--
					The AspectMatcher provides a method for determines the next Aspect in
					the chain. The matcher examines the URL for a prefixed aspectID, such
					as 1/ or 3/. This number is then used to examine which Aspect to load
					from the chain.
					
					The matcher creates several sitemap parameters to describe the Aspect,
					{aspect} - The path name of the aspect
					{prefix} - The url-prefix, such as 1/ or 3/
					{ID} - The Aspect's ID number in the chain, such as 1 or 3.
					-->
			<map:matcher name="AspectMatcher" src="org.dspace.app.xmlui.cocoon.AspectMatcher"/>
		</map:matchers>
		
		<map:transformers>
		
			<!-- 	
					The PageNotFound transformer watches for empty pages generated by the
					aspect chain. When it finds an empty page it inserts page not found content. 
					-->
			<map:transformer name="PageNotFound" src="org.dspace.app.xmlui.aspect.general.PageNotFoundTransformer"/>
		</map:transformers>
		
	</map:components>
	
	<map:pipelines>
		
		<!--
		  	This internal-only pipeline handles the generation of all DRI pages. This 
		  	is reached by two methods, either the request is generated by a theme, or 
		  	the non-internal-only pipeline below. 
		  	
		  	The Aspect Matcher examines the URL and decides what the next aspect in the
		  	chain is. Serveral aspect-dependent variables are created: "aspectID" contains
		  	integer id of the aspect, "aspect" contains source path of the aspect, aspectName
		  	contains the name of the aspect, and prefix contains the url prefix that should
		  	be removed from the url before processing by an aspect.
		  	
		  	The system has a concept of a zero aspect which consists of a special transformer 
		  	to check if the page generated by the aspect chain is empty, if it is then a page
		  	not found division is added to the resulting page. Thus the aspect chain really 
		  	is 1 through n+1, where n is the number of aspects.
		  	
		  	Each time through this look the aspects sitemap is loaded which 
		  	in turn generates another internal request for the next Aspect where the
		  	AspectMatcher again selects the next Aspect until there are no more Aspects left
		  	to be chained. When this happens the AspectMatcher fails and the following snip 
		  	is invoked which loads the protodocument.xml to kickstart the Aspect chain.
		     -->
		<map:pipeline internal-only="yes">
			
			<map:match type="AspectMatcher">
				<map:select type="parameter">
					<map:parameter name="parameter-selector-test" value="{aspectID}"/>
					
					<map:when test="0">
						<map:generate/>
						<map:transform type="PageNotFound"/>
						<map:serialize type="xml"/>
					</map:when>
					
					<map:otherwise>
						<map:mount uri-prefix="{prefix}" check-reload="" src="{aspect}"/>		
					</map:otherwise>
					
				</map:select>
			</map:match>
			
			<map:generate type="file" src="protodocument.xml"/>
			<map:serialize type="xml"/>
			
		</map:pipeline>
		
		
		<!--
				This pipeline is a nifty trick, it is not normally executed because all aspect 
				URL are generated internal. When this pipeline is invoked it is because the user
				typed in a URL that is prefixed with the path "/DRI/". In this case they are 
				requesting the actual DRI document. To make the document easier to read this
				pipeline applies an i18n step to translate it.
		 		 -->
		<map:pipeline>
			<map:match type="wildcard" pattern="**">
				<map:generate type="file" src="cocoon://DRI/{1}"/>
				<map:act type="locale">
					<map:transform type="i18n">
						<map:parameter name="locale" value="{locale}"/>						
					</map:transform>
				</map:act>
				<map:serialize type="xml"/>
			</map:match>
	  </map:pipeline>			
	  
	  
	</map:pipelines>
</map:sitemap>
