<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:ns2="http://cdm-fr.fr/2011/CDM-frSchema" exclude-result-prefixes="xsl">
	<xsl:key name="formation" match="program | subProgram" use="@id"/>
	<xsl:output method="xml"/>
	<xsl:param name="referentiel">constantes.sample</xsl:param>
	<xsl:param name="codAnu">2006</xsl:param>
	<xsl:param name="dateCreation"/>
	<xsl:param name="type"/>
	<xsl:param name="oid"/>
	<xsl:param name="url"/>
	<xsl:variable name="codes" select="document(concat('file://',$referentiel,'.xml'))/constantes"/>
	<xsl:include href="customoai.xsl"/>
	<!-- génération de l'enregistrement oai incluant dublin core et cdm-fr -->
	<xsl:template match="/">
		<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.openarchives.org/OAI/2.0/">
			<header>
				<identifier>
					<xsl:value-of select="concat($oid,$type,$codAnu)"/>
				</identifier>
				<datestamp>
					<xsl:value-of select="$dateCreation"/>
				</datestamp>
				<setSpec>catalogue-of</setSpec>
			</header>
			<metadata>
				<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xs="http://www.w3.org/2001/XMLSchema" dc:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ 
					http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
					<xsl:call-template name="oai_dc_template"/>
				</oai_dc:dc>
				<xsl:call-template name="cdm_template" />

			</metadata>
		</record>
	</xsl:template>
	<!-- prise en compte de l'intitulé de la formation -->
	<xsl:template match="programName/text" xmlns:dc="http://purl.org/dc/elements/1.1/" mode="dc">
		<dc:title>
			<xsl:value-of select="."/>
		</dc:title>
	</xsl:template>
	<!-- TRAITEMENT DU PREFIX DUBLIN CORE -->
	<xsl:template name="oai_dc_template" xmlns:dc="http://purl.org/dc/elements/1.1/">
		<xsl:apply-templates select="key('formation', $oid)/programName/text" mode="dc"/>
		<dc:creator>uniform</dc:creator>
		<dc:subject>CDM-FR</dc:subject>
		<dc:description/>
		<dc:date>
			<xsl:value-of select="$dateCreation"/>
		</dc:date>
		<dc:identifier>
			<xsl:call-template name="url"/>
		</dc:identifier>
	</xsl:template>
</xsl:stylesheet>
