<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- program.v01.xsl contient tous les templates d'affichage des informations d'un programme (balise program) de CDM-fr v2 -->

<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:ns2="http://cdm-fr.fr/2011/CDM-frSchema"
	exclude-result-prefixes="xsl xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:xhtml="http://www.w3.org/1999/xhtml"
	xmlns:fo="http://www.w3.org/1999/XSL/Format"
	xmlns:functx="http://www.functx.com">

	<!-- AJOUT ROT template description -->
	<xsl:template name="tProgramProgramID">
		<xsl:apply-templates select="key('objet',$idP)/programID"/>
	</xsl:template>

	<xsl:template name="tProgramWebLinkHref">
		<xsl:apply-templates select="key('objet',$idP)/ns2:webLink/href"/>
	</xsl:template>
	
	<xsl:template name="tProgramProgramName">
		<xsl:apply-templates select="key('objet',$idP)/ns2:programName/ns2:text[@language=$_lang or not(@language)]"/>
	</xsl:template>
	
	<xsl:template name="tProgramProgramCode">
		<xsl:param name="pCodeSet"/>
		<!-- Valeurs possibles: sectDGESIP sectDiscipSISE codeCNIS-NSF cite97 régimeInscriptionSise ERASMUS FAP userDefined -->
		<!-- Faut-il prevoir un cas ou on renvoit la valeur quelque soit le parametre ? -->
		<xsl:if test="not($pCodeSet='')">
			<xsl:apply-templates select="key('objet',$idP)/ns2:programCode[@codeSet=$pCodeSet]"/>
		</xsl:if>
	</xsl:template>
	
	<xsl:template name="tProgramProgramDescriptionInfoBlock">
		<xsl:apply-templates select="key('objet',$idP)/ns2:programDescription/infoBlock"/>
	</xsl:template>

	<xsl:template name="tProgramProgramDescriptionTeachingTeamInfoBlock">
		<xsl:apply-templates select="key('objet',$idP)/ns2:programDescription/ns2:teachingTeam/infoBlock"/>
	</xsl:template>
	
	<xsl:template name="tProgramProgramDescriptionTeachingTeamGlobalVolume">
		<xsl:param name="pTeachingTypeSet"/>
		<!-- Valeurs possibles: CM, TD, TP, trainingWeeks, professTraining, homeWork, all -->
		<!-- Faut-il prevoir un cas ou on renvoit la valeur quelque soit le parametre ? -->
		<xsl:if test="not($pTeachingTypeSet='')">
			<xsl:apply-templates select="key('objet',$idP)/ns2:programDescription/ns2:teachingTeam/globalVolume[@teachingtype=$pTeachingTypeSet]"/>
		</xsl:if>
	</xsl:template>
	
	<xsl:template name="tProgramProgramDescriptionNature">
		<!-- Faut-il prevoir un cas ou on renvoit la valeur quelque soit le parametre ? -->
		<!-- Ne contient que la valeur semestre ou année. N'est pas alimenté pour mention -->
		<xsl:apply-templates select="key('objet',$idP)/ns2:programDescription/@nature"/>
	</xsl:template>
	
	<xsl:template name="tProgramQualificationQualificationDescription">
		<xsl:apply-templates select="key('objet',$idP)/qualification/ns2:qualificationDescription/infoBlock[@blockLang=$_lang or not(@blockLang)]"/>
	</xsl:template>
	
	<xsl:template name="tProgramQualificationStudyQualificationInfoBlock">
		<xsl:apply-templates select="key('objet',$idP)/qualification/ns2:studyQualification/infoBlock[@blockLang=$_lang or not(@blockLang)]"/>
	</xsl:template>
	
	<xsl:template name="tProgramQualificationProfession">
		<xsl:apply-templates select="key('objet',$idP)/qualification/ns2:profession/infoBlock[@blockLang=$_lang or not(@blockLang)]"/>
	</xsl:template>
	
	<xsl:template name="tProgramLearningObjectives">
		<xsl:apply-templates select="key('objet',$idP)/learningObjectives[@blockLang=$_lang or not(@blockLang)]/node()"/>
	</xsl:template>
        <xsl:template name="tProgramLearningObjectiveshead">
                <xsl:apply-templates select="key('objet',$idP)/learningObjectives/header"/>
        </xsl:template>
	
	<xsl:template name="tProgramQualificationCredits">
		<xsl:value-of select="key('objet',$idP)/qualification/ns2:credits/@ECTScredits"/>
	</xsl:template>
	
	<xsl:template name="tProgramQualificationDegree">
		<xsl:value-of select="key('objet',$_oid)/qualification/ns2:degree/@degree"/>
	</xsl:template>
	
	<xsl:template name="tProgramQualificationDegreeInfoBlockType">
		<xsl:value-of select="key('objet',$idP)/qualification/ns2:degree/node()"/>
	</xsl:template>
	
	<xsl:template name="tProgramQualificationProfessionRomeData">
		<ul>
			<xsl:for-each select="key('objet',$idP)/qualification/ns2:profession/ns2:romeData/ns2:text[@language=$_lang or not(@language)]">
				<li>
					<xsl:value-of select="."/>
				</li>
			</xsl:for-each>
		</ul>
	</xsl:template>
	
	<xsl:template name="tProgramQualificationProfessionRomeDataPdf">
		<fo:list-block>	
			<xsl:for-each select="key('objet',$idP)/qualification/ns2:profession/ns2:romeData/ns2:text[@language=$_lang or not(@language)]">
				<fo:list-item>
					<fo:list-item-label><fo:block>&#x2022;</fo:block></fo:list-item-label>
					<fo:list-item-body start-indent="4pt">
						<fo:block>
							<xsl:value-of select="."/>
						</fo:block>
					</fo:list-item-body>
				</fo:list-item>		
			</xsl:for-each>
		</fo:list-block>	
	</xsl:template>
	
	<xsl:template name="tProgramStudyAbroad">
		<ul>
			<xsl:for-each select="key('objet',$idP)/studyAbroad[@blockLang=$_lang or not(@blockLang)]">
				<li>
					<xsl:apply-templates select="node()"/>
				</li>
			</xsl:for-each>
		</ul>
	</xsl:template>
	
	<xsl:template name="tProgramStudyAbroadPdf">
		<fo:list-block>
			<xsl:for-each select="key('objet',$idP)/studyAbroad[@blockLang=$_lang or not(@blockLang)]">
				<fo:list-item>
					<fo:list-item-label><fo:block>&#x2022;</fo:block></fo:list-item-label>
					<fo:list-item-body start-indent="4pt">
						<fo:block>
							<xsl:apply-templates select="node()"/>
						</fo:block>
					</fo:list-item-body>
				</fo:list-item>	
			</xsl:for-each>
		</fo:list-block>
	</xsl:template>

	<xsl:template name="tProgramProgramIntroduction">
		<xsl:apply-templates select="key('objet',$idP)/programIntroduction[@blockLang=$_lang or not(@blockLang)]/node()"/>
	</xsl:template>
	
	<xsl:template name="tProgramUniversalAdjustment">
		<xsl:apply-templates select="key('objet',$idP)/universalAdjustment[@blockLang=$_lang or not(@blockLang)]/node()"/>
	</xsl:template>
	
	<xsl:template name="tProgramAdmissionInfoAdmissionDescription">
		<xsl:apply-templates select="key('objet',$idP)/admissionInfo/ns2:admissionDescription[@blockLang=$_lang or not(@blockLang)]/node()"/>
	</xsl:template>
	<xsl:template name="tProgramAdmissionInfoStudentPlaces">
		<xsl:value-of select="key('objet',$idP)/admissionInfo/studentPlaces[@blockLang=$_lang or not(@blockLang)]/@places"/>
	</xsl:template>
	<xsl:template name="tProgramAdmissionInfoRegistrationStartDate">
		<xsl:value-of select="key('objet',$idP)/admissionInfo/ns2:registrationStart[@blockLang=$_lang or not(@blockLang)]/@date"/><xsl:text> </xsl:text><xsl:value-of select="key('objet',$idP)/admissionInfo/ns2:registrationStart[@blockLang=$_lang or not(@blockLang)]/@time"/>
	</xsl:template>
	<xsl:template name="tProgramAdmissionInforegistrationDeadlineDate">
		<xsl:value-of select="key('objet',$idP)/admissionInfo/registrationDeadline[@blockLang=$_lang or not(@blockLang)]/@date"/><xsl:text> </xsl:text><xsl:value-of select="key('objet',$idP)/admissionInfo/registrationDeadline[@blockLang=$_lang or not(@blockLang)]/@time"/>
	</xsl:template>
	<xsl:template name="tProgramAdmissionInfostudentStatus">
		<xsl:apply-templates select="key('objet',$idP)/admissionInfo/ns2:studentStatus[@blockLang=$_lang or not(@blockLang)]/node()"/>
	</xsl:template>
	
	<xsl:template name="tProgramAipPossibleFollowUp">
		<xsl:apply-templates select="key('objet',$idP)/ns2:aip/ns2:possibleFollowUp"/>
	</xsl:template>
	<xsl:template name="tProgramAipSuccessSupport">
		<xsl:apply-templates select="key('objet',$idP)/ns2:aip/ns2:successSupport"/>
	</xsl:template>
	<xsl:template name="tProgramAipLearningPathStrategySupport">
		<xsl:apply-templates select="key('objet',$idP)/ns2:aip/ns2:learningPathStrategySupport"/>
	</xsl:template>
	<xsl:template name="tProgramAipProfessTrainingSupport">
		<xsl:apply-templates select="key('objet',$idP)/ns2:aip/ns2:professTrainingSupport"/>
	</xsl:template>
	
	<xsl:template name="tProgramExpensesInfoBlockType">
		<xsl:call-template name="tExpensesInfoBlockType">
			<xsl:with-param name="pNode" select="key('objet',$idP)"/>
		</xsl:call-template>
	</xsl:template>
	
	<xsl:template name="tProgramExpensesPrice">
		<xsl:call-template name="tExpensesPrice">
			<xsl:with-param name="pNode" select="key('objet',$idP)"/>
		</xsl:call-template>
	</xsl:template>

	<xsl:template name="tProgramFormalPrerequisites">
		<xsl:call-template name="tFormalPrerequisitesInfoBlockType">
			<xsl:with-param name="pNode" select="key('objet',$idP)"/>
		</xsl:call-template>
	</xsl:template>
	
	<xsl:template name="tProgramRecommendedPrerequisites">
		<xsl:call-template name="tRecommendedPrerequisitesInfoBlockType">
			<xsl:with-param name="pNode" select="key('objet',$idP)"/>
		</xsl:call-template>
	</xsl:template>

	<xsl:template name="tProgramProgramStructureInfoBlock">
		<xsl:apply-templates select="key('objet',$idP)/ns2:programStructure/infoBlock[@blockLang=$_lang or not(@blockLang)]"/>
	</xsl:template>
	
	<xsl:template name="tProgramProgramStructureRefProgram">
		<xsl:if test="count(key('objet',$idP)/ns2:programStructure/ns2:refProgram)&gt;0">
			<ul>
				<xsl:apply-templates select="key('objet',$idP)/ns2:programStructure/ns2:refProgram"/>
			</ul>
		</xsl:if>
	</xsl:template>

	<xsl:template name="tProgramRefProgramProgramNameText">
		<xsl:param name="pRef"/>
		<!--<xsl:value-of select="/CDM/program[@ident=$pRef]/ns2:programName/ns2:text[@language=$_lang or not(@language)]"/>-->
		<xsl:value-of select="key('objet',@ref)/ns2:programName/ns2:text[@language=$_lang or not(@language)]"/>
	</xsl:template>
	
	<xsl:template name="tProgramRegulations">
		<xsl:apply-templates select="key('objet',$idP)/regulations[@blockLang=$_lang or not(@blockLang)]/node()"/>
	</xsl:template>
	
	<xsl:template name="tProgramFormOfAssessmentInfoBlock">
		<xsl:call-template name="tFormOfAssessmentInfoBlockType">
			<xsl:with-param name="pNode" select="key('objet',$idP)"/>
		</xsl:call-template>
	</xsl:template>
	
	<xsl:template name="tProgramLevel">
		<xsl:call-template name="tLevelLevel">
			<xsl:with-param name="pNode" select="key('objet',$idP)"/>
		</xsl:call-template>
	</xsl:template>
	
	<xsl:template name="tProgramLearningObjectivesInfoBlockType">
		<xsl:call-template name="tLearningObjectivesInfoBlockType">
			<xsl:with-param name="pNode" select="key('objet',$idP)"/>
		</xsl:call-template>
	</xsl:template>
	
	<xsl:template name="tProgramPpalTeachingLanguage">
		<xsl:value-of select="key('objet',$idP)/ns2:ppalTeachingLanguage/@teachingLang"/>
	</xsl:template>
	
	<xsl:template name="tProgramLevelCode">
		<xsl:value-of select="key('objet',$idP)/levelCode/@codeSet"/>
	</xsl:template>
	
	<!-- Templates utilises en local uniquement (appeles par des apply-templates de ce même fichier) -->
	<!--<xsl:template match="ns2:programStructure[ns2:refCourse]" >		
		<xsl:if test="count(ns2:refCourse)&gt;0"><ul><xsl:apply-templates select="ns2:refCourse"/></ul></xsl:if>
	</xsl:template>
	<xsl:template match="ns2:refProgram">
		<li><a href="{$absActionURL}/{$_lang}/fiche/description/{$_oid}/{@ref}"><xsl:if test="count(key('objet',@ref)/ns2:programName/ns2:text[@language=$_lang or not(@language)])=0">Sans nom</xsl:if><xsl:value-of select="key('objet',@ref)/ns2:programName/ns2:text[@language=$_lang or not(@language)]"/></a></li>
	</xsl:template>-->
	
	<xsl:template name="tProgramAdmissionInfoEctsRequiredValue">
		<xsl:value-of select="sum(key('objet',$idP)/admissionInfo/ns2:ectsRequired[@blockLang=$_lang or not(@blockLang)]/@value)"/>
	</xsl:template>
	
	<xsl:template name="tProgramProgramDurationDuration">
		<xsl:value-of select="key('objet',$idP)/programDuration[@blockLang=$_lang or not(@blockLang)]/@duration"/>
	</xsl:template>

	<xsl:template name="tProgramTargetGroup">
		<xsl:apply-templates select="key('objet',$idP)/targetGroup[@blockLang=$_lang or not(@blockLang)]"/>
	</xsl:template>
	
	<xsl:template match="teachingPlace">
		<xsl:value-of select="adr/extadr"/><xsl:text> </xsl:text>, 
		<xsl:value-of select="adr/street"/><xsl:text>, 
		</xsl:text><xsl:value-of select="adr/pcode"/><xsl:text> </xsl:text>
		<xsl:value-of select="adr/locality"/>
	</xsl:template>
	
	<xsl:template name="tProgramTeachingPlaceInfoBlock">
		<xsl:apply-templates select="key('objet',$idP)/teachingPlace[@blockLang=$_lang or not(@blockLang)]/infoBlock"/>
	</xsl:template>
	
	<xsl:template name="tProgramTeachingPlaceAdrExtadr">
		<xsl:value-of select="key('objet',$idP)/teachingPlace[@blockLang=$_lang or not(@blockLang)]/adr/extadr"/>
	</xsl:template>
	
	<xsl:template name="tProgramTeachingPlaceAdrStreet">
		<xsl:value-of select="key('objet',$idP)/teachingPlace[@blockLang=$_lang or not(@blockLang)]/adr/street"/>
	</xsl:template>
	
	<xsl:template name="tProgramTeachingPlaceAdrPcode">
		<xsl:value-of select="key('objet',$idP)/teachingPlace[@blockLang=$_lang or not(@blockLang)]/adr/pcode"/>
	</xsl:template>

	<xsl:template name="tProgramTeachingPlaceAdrLocality">
		<xsl:value-of select="key('objet',$idP)/teachingPlace[@blockLang=$_lang or not(@blockLang)]/adr/locality"/>
	</xsl:template>

	
	<!-- Templates composes -->
	<xsl:template name="tResumeFormation">
		<h3><xsl:call-template name="tCommunGestionLibelle"><xsl:with-param name="pIdent" select="'libResumeFormation'"/></xsl:call-template></h3>
		<ul>
			<li><xsl:call-template name="tCommunGestionLibelle"><xsl:with-param name="pIdent" select="'libAdresseEnseignement'"/></xsl:call-template>
			<xsl:apply-templates select="key('objet',$idP)/teachingPlace/infoBlock"/></li>
		</ul>
	</xsl:template>
	
	<!-- Templates composes -->
	<xsl:template name="tEstUneMention">
	  <xsl:variable name="vProgramID">
	    <xsl:call-template name="tProgramProgramID"/>
	  </xsl:variable>
	  <xsl:choose>
	    <xsl:when test="substring($vProgramID,16,2)='ME'"><xsl:value-of select="true()"/></xsl:when>
	    <xsl:otherwise><xsl:value-of select="false()"/></xsl:otherwise>
	  </xsl:choose>
	</xsl:template>
	<xsl:template name="tEstUneLicence">
	  <xsl:variable name="type"><xsl:call-template name="tProgramQualificationDegree"/></xsl:variable>
	  <xsl:choose>
	    <xsl:when test="$type = 'licence'"><xsl:value-of select="true()"/></xsl:when>
	    <xsl:otherwise><xsl:value-of select="false()"/></xsl:otherwise>
	  </xsl:choose>
	</xsl:template>
	<xsl:template name="tEstUnMaster">
	  <xsl:variable name="type"><xsl:call-template name="tProgramQualificationDegree"/></xsl:variable>
	  <xsl:choose>
	    <xsl:when test="$type = 'master'"><xsl:value-of select="true()"/></xsl:when>
	    <xsl:otherwise><xsl:value-of select="false()"/></xsl:otherwise>
	  </xsl:choose>
	</xsl:template>

	<!-- Extraction nom de la mention du programName / isa	 -->
	<xsl:template name="tProgramMentionName">
		<xsl:variable name="vProgramNameText" select="key('objet', $_oid)/ns2:programName/ns2:text[@language=$_lang or not(@language)] | key('objet',$_oid)/courseName/text"/>
		<xsl:value-of select="substring-after($vProgramNameText,'MENTION : ')"/>
	</xsl:template>


</xsl:stylesheet>
