<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- ========================================== -->
<!-- Curriculum Vitae XSL File by Daniel Werner -->
<!-- intended to convert the XML file into PDF. -->
<!-- mailto: werner@efrei.fr                    -->
<!-- ========================================== -->
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes" encoding="ISO-8859-1"/>

	<xsl:template match="*"/>

	<!-- Resume -->
	<xsl:template match="file">

	<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  		<fo:layout-master-set>
        <fo:simple-page-master master-name="first"
          page-height="29.7cm"
          page-width="21cm"
          margin-top="0.5cm"
          margin-bottom="0.5cm"
          margin-left="2cm"
          margin-right="2cm">
	  
	  			<fo:region-body />
					<fo:region-after extent="20pt" display-align="before" padding="6pt 1in"/> 	  			
       	</fo:simple-page-master>      	
      </fo:layout-master-set>
	  
    	<fo:page-sequence master-reference="first">	
    	
		    <fo:static-content flow-name="xsl-region-after" font-family="Times" font-size="8pt">
					<fo:block>
						<fo:leader leader-length="100%" leader-pattern="rule" rule-thickness="1pt" color="black"/>
					</fo:block>
		      	<xsl:apply-templates select="notice"/>
		    </fo:static-content>
		    		    
        <!-- BODY -->
        <fo:flow flow-name="xsl-region-body">
          <xsl:apply-templates select="resume"/> 
        </fo:flow>	

      </fo:page-sequence>
      
    </fo:root>

  </xsl:template>

	<!-- Notice de bas de page -->
	<xsl:template match="notice">
		<fo:block>
			<xsl:apply-templates />
		</fo:block>
	</xsl:template>

	<!-- Resume -->
	<xsl:template match="resume">
		<xsl:apply-templates />
	</xsl:template>

	<!-- Section -->
  <xsl:template match="section">
  
  	<xsl:if test="@onCV='true'">
	    <xsl:if test="@showtitle='true'">
	      <fo:block font-variant="small-caps" font-family="Times" font-size="12pt" font-weight="bold" text-align-last="start">
					<xsl:value-of select="concat(@title, ' ')"/>
	      </fo:block>
	      <fo:block space-before="-8pt">
	        <fo:leader leader-length="100%" leader-pattern="rule" rule-thickness="3pt" color="black"/>
	      </fo:block>
	      <fo:block space-before="-10pt">
	        <fo:leader leader-length="100%" leader-pattern="rule" rule-thickness="1pt" color="black"/>
	      </fo:block>
	    </xsl:if>
	        
	    <fo:block padding="8pt" font-family="Times" font-size="9pt">
	      <xsl:apply-templates />
	    </fo:block>
	  </xsl:if>
  </xsl:template>

  <!-- Contact Information -->
  <xsl:template match="contact">
    <fo:block text-align="center">
     	<xsl:apply-templates select="name" mode="contact"/>
    	<fo:block>
        <xsl:apply-templates select="born"/> [<xsl:apply-templates select="age"/>]
			</fo:block>
      <fo:block>
        <xsl:apply-templates select="nationalite"/>
      </fo:block>
      <fo:block>
	  		<fo:inline><xsl:apply-templates select="situation"/> -
	  		</fo:inline>
	  		<xsl:apply-templates select="permis"/>
      </fo:block>           
    </fo:block>
    <fo:block>
    <fo:table table-layout="fixed">
        <fo:table-column column-width="14cm" />
    	<fo:table-column column-width="4cm"/> 
    	<fo:table-body>
	  <fo:table-row>
            <fo:table-cell>
              <fo:block margin-left="-0.75cm">
                <fo:block font-weight="bold"><xsl:value-of select="addractu" /></fo:block>
	        			<xsl:apply-templates select="address" mode="contact"/>
	        			<fo:block>Mob.: <fo:inline><xsl:apply-templates select="portable"/></fo:inline></fo:block>
	     			 </fo:block>
	    		</fo:table-cell>
    	    <fo:table-cell>
    	      <fo:block margin-right="-1.25cm">
               <fo:block font-weight="bold"><xsl:value-of select="addrperm" /></fo:block>
	        		<xsl:apply-templates select="address2" mode="contact"/>
							<xsl:apply-templates select="email"/>    	      
    	      </fo:block>
    	    </fo:table-cell>
    	</fo:table-row>
      </fo:table-body>
    </fo:table>
    </fo:block>
  </xsl:template>

  <xsl:template match="name" mode="contact">
    <fo:block font-family="Times" font-size="13pt" space-after="6pt">
    	<xsl:apply-templates />
    </fo:block>
  </xsl:template>

  <xsl:template match="telephone">
    	<xsl:value-of select="."/>
  </xsl:template>
  
  <xsl:template match="portable">
    	<xsl:value-of select="."/>
  </xsl:template>

  <xsl:template match="born">
    	<xsl:apply-templates />
  </xsl:template>
    
  <xsl:template match="age">
    	<xsl:value-of select="."/>
  </xsl:template>
  
  <xsl:template match="nationalite">
    	<xsl:apply-templates />
  </xsl:template>
  
  <xsl:template match="situation">
    	<xsl:value-of select="."/>
  </xsl:template>
  
  <xsl:template match="permis">
    	<xsl:value-of select="."/>
  </xsl:template>
  
  <xsl:template match="email">
    <fo:basic-link color="#0000C0">
      <xsl:attribute name="external-destination">mailto:<xsl:value-of select="."/></xsl:attribute>
      <xsl:value-of select="."/>
    </fo:basic-link>
  </xsl:template>

  <xsl:template match="address" mode="contact">
    <fo:block>
    	<xsl:value-of select="concat(number, ' ')"/>, 
        <xsl:value-of select="street"/>
    </fo:block>
    <fo:block text-decoration="underline">
    	<xsl:value-of select="concat(zip-code, ' ')"/>
        <xsl:value-of select="concat(city, ' ')"/>
    </fo:block>
    <fo:block>
        <!-- <xsl:value-of select="country"/> -->
        Tél.: <fo:inline><xsl:apply-templates select="telephone"/></fo:inline>
    </fo:block>
  </xsl:template>
  
  <xsl:template match="address2" mode="contact">
    <fo:block>
    	<xsl:value-of select="concat(number, ' ')"/>, 
        <xsl:value-of select="street"/>
    </fo:block>
    <fo:block text-decoration="underline">
    	<xsl:value-of select="concat(zip-code, ' ')"/>
        <xsl:value-of select="concat(city, ' ')"/>
    </fo:block>
    <fo:block>
        <!-- <xsl:value-of select="country"/> -->
        Tél.: <fo:inline><xsl:apply-templates select="telephone"/></fo:inline>
    </fo:block>
  </xsl:template>

  <!-- Objective -->
  <xsl:template match="objective">
	    <fo:block text-align="center" font-family="Times" font-size="14pt" font-weight="bold" >
	      <xsl:value-of select="."/>
	    </fo:block>
  </xsl:template>

  <!-- Education -->
  <xsl:template match="education">
    <fo:block>
      <xsl:apply-templates select="degree"/>
    </fo:block>
  </xsl:template>
     
  <xsl:template match="degree">
    <fo:block>
      <fo:table table-layout="fixed" padding-after="6pt">
      	<fo:table-column column-width="3cm" />
      	<fo:table-column />
      	<fo:table-body>
  	  		<fo:table-row>
            <fo:table-cell>
              <!-- <fo:block font-family="Courier" font-size="10pt"> -->
              <fo:block font-style="italic">
                <xsl:apply-templates select="date"/>
              </fo:block>
            </fo:table-cell>
            <fo:table-cell padding-after="1pt">
    	      	<fo:block>            
                <fo:inline><xsl:apply-templates select="institution"/></fo:inline> : <xsl:apply-templates select="longname"/>
              </fo:block>
							<xsl:apply-templates select="oldname" mode="education"/>
            </fo:table-cell>
          </fo:table-row>
          <fo:table-row>
            <fo:table-cell/>
            <fo:table-cell>
              <xsl:apply-templates select="description" mode="education"/>
              <xsl:apply-templates select="description2" mode="education"/>
            </fo:table-cell>
          </fo:table-row>
        </fo:table-body>
      </fo:table>
    </fo:block>
  </xsl:template>

  <xsl:template match="longname">
      <xsl:value-of select="."/>
  </xsl:template>

  <xsl:template match="oldname" mode="education">
    <fo:block>
      <xsl:value-of select="."/>
    </fo:block>
  </xsl:template>

  <xsl:template match="description" mode="education">
    <fo:block>
      <xsl:value-of select="."/>
    </fo:block>
  </xsl:template>

  <xsl:template match="description2" mode="education">
    <fo:block>
      <xsl:apply-templates />
    </fo:block>
  </xsl:template>
  
  <xsl:template match="date">
      <xsl:value-of select="concat(@day, ' ')"/>
      <xsl:value-of select="concat(@month, ' ')"/>
      <xsl:value-of select="@year"/>
  </xsl:template>

  <xsl:template match="institution">
      <fo:inline font-weight="bold">
        <xsl:apply-templates select="name"/>
      </fo:inline>
      <xsl:apply-templates select="address"/> 
  </xsl:template>

  <xsl:template match="name">
      <xsl:apply-templates />
			<xsl:value-of select="concat(./name, ', ')" />      
  </xsl:template>

  <xsl:template match="address">
		<xsl:if test="number">  
      <xsl:value-of select="concat(number, ' ')"/>
    </xsl:if>
    <xsl:if test="street"> 
      <xsl:value-of select="concat(street, ' ')"/>
    </xsl:if>
    <xsl:if test="zip-code"> 
      <xsl:value-of select="concat(zip-code, ' ')"/>
    </xsl:if>
    <xsl:if test="city" > 
      	<xsl:value-of select="city"/>
    </xsl:if>
    <xsl:if test="country"> 
      <fo:inline font-weight="bold">
      	<xsl:value-of select="country"/>
      </fo:inline>
    </xsl:if>
  </xsl:template>

  <!-- Languages -->
  <xsl:template match="languages">
    <fo:block>
      <xsl:apply-templates select="language"/>
    </fo:block>
  </xsl:template>

  <xsl:template match="language">
    <fo:block>
      <fo:table table-layout="fixed" padding-after="6pt">
      	<fo:table-column column-width="3cm" />
    		<fo:table-column />
    		<fo:table-body>
	  			<fo:table-row>
            <fo:table-cell>    	
              <xsl:apply-templates select="langue" mode="languages"/>
	    			</fo:table-cell>
    	    	<fo:table-cell>
              <xsl:apply-templates select="desc" mode="languages"/>
    	    	</fo:table-cell>
		    	</fo:table-row>
    	  </fo:table-body>
    	</fo:table>
    </fo:block>
  </xsl:template>

	<xsl:template match="langue" mode="languages">
    <fo:block font-style="italic">
      <xsl:value-of select="."/>
    </fo:block>
	</xsl:template>

	<xsl:template match="desc" mode="languages">
		<xsl:if test="@onWEB='false'">
    	<fo:block>
				<xsl:apply-templates />
			</fo:block>
		</xsl:if>
 	</xsl:template>
  
  <!-- Skills -->
  <xsl:template match="skillset">
    <fo:block>
      <xsl:apply-templates select="skill" />
    </fo:block>
  </xsl:template>
 
  <xsl:template match="skill">
    <fo:block>
      <fo:table table-layout="fixed" padding-after="6pt">
        <fo:table-column column-width="3cm" />
    		<fo:table-column />
    		<fo:table-body>
	  			<fo:table-row>
        		<fo:table-cell> 
				      <fo:block font-style="italic">
				        <xsl:value-of select="name" />
				      </fo:block>
	    			</fo:table-cell>
    	    	<fo:table-cell>
				      <fo:block>
				        <xsl:apply-templates select="skillDescription" />
				      </fo:block>
    	    	</fo:table-cell>
    			</fo:table-row>
      	</fo:table-body>
    	</fo:table>
    </fo:block>
  </xsl:template>
  
  <xsl:template match="skillDescription">
		<xsl:apply-templates />  	
  </xsl:template>

  <xsl:template match="desc">
    <fo:inline>
      <xsl:value-of select="."/>   
    </fo:inline>
  </xsl:template>

  <!-- Professional Experience -->
  <xsl:template match="employment-history">
  	<xsl:if test="@onCV='true'">  
   		<fo:block>
	      <xsl:apply-templates select="experience"/>
   		</fo:block>
    </xsl:if>
  </xsl:template>
  
  <xsl:template match="experience">
    <fo:block>
      <fo:table table-layout="fixed" padding-after="8pt">
      	<fo:table-column column-width="3cm" />
      	<fo:table-column />
      	<fo:table-body>
  	  <fo:table-row>
            <fo:table-cell number-rows-spanned="3">
              <fo:block>
                <xsl:apply-templates select="period"/>
              </fo:block>
              <!--
					    <fo:block>
					    	<fo:inline font-size="8pt" font-style="italic"><xsl:apply-templates select="duree" /></fo:inline>
					    </fo:block>
					    -->
            </fo:table-cell>
          </fo:table-row>
          <fo:table-row>
            <fo:table-cell>
            	<fo:block>
              	<xsl:apply-templates select="employer"/>&#160;
              	<xsl:apply-templates select="duree" />
              </fo:block>
              <fo:block>
								<xsl:apply-templates select="expDesc"/>
							</fo:block>
            </fo:table-cell>
          </fo:table-row>
        </fo:table-body>
      </fo:table>
    </fo:block>   
  </xsl:template>
  	
  <xsl:template match="period">
    <!-- <fo:block font-family="Courier" font-size="10pt"> -->
    <fo:block font-style="italic">
      <fo:block>
        <xsl:value-of select="concat(start-date/@month, ' ')"/>
        <xsl:value-of select="start-date/@year"/> 
      </fo:block>
			<xsl:if test="end-date">
	      <fo:block>
	      	<xsl:value-of select="to"/> <xsl:value-of select="concat(end-date/@month, ' ')"/>
	        <xsl:value-of select="end-date/@year"/>
	      </fo:block>
	    </xsl:if>
    </fo:block>
  </xsl:template> 
  
  <xsl:template match="employer">
    <fo:inline>
			<fo:basic-link font-variant="small-caps" font-weight="bold" color="#232579">
				<xsl:attribute name="external-destination"><xsl:value-of select="homepage"/></xsl:attribute>
				<xsl:value-of select="name"/>
			</fo:basic-link>      
			(<fo:inline><xsl:apply-templates select="address"/></fo:inline>) - 
			<fo:inline font-style="italic"><xsl:value-of select="concat(' ',detailSociete)"/></fo:inline> 
    </fo:inline>
  </xsl:template>

	<xsl:template match="duree">
			<xsl:if test="@onCV='true'">
				<xsl:value-of select="."/>.
			</xsl:if>
	</xsl:template>

  <xsl:template match="expDesc">
  	<fo:inline>
  		<xsl:if test="departement">
  			<xsl:value-of select="departement"/>. 
  		</xsl:if>
  		<xsl:apply-templates select="short-description"/>
		</fo:inline>
  </xsl:template>

  <xsl:template match="short-description">
  	<fo:inline>
  		<xsl:apply-templates select="statement"/> 
		</fo:inline>
  </xsl:template>

  <xsl:template match="statement">
      <xsl:apply-templates /><fo:block></fo:block>
  </xsl:template>
  
  <xsl:template match="title">
    <fo:inline font-weight="bold">
      <xsl:value-of select="."/> 
    </fo:inline>
  </xsl:template> 
    
  <!-- Projects
  <xsl:template match="name" mode="project">
    <fo:inline font-weight="bold">
      <xsl:value-of select="."/> 
    </fo:inline>
  </xsl:template> 
  
  <xsl:template match="projects">
    <fo:block>
      <xsl:apply-templates select="project" />
    </fo:block>
  </xsl:template>
  
    <xsl:template match="project">
    <fo:block>
      <fo:table table-layout="fixed" padding-after="6pt">
      	<fo:table-column column-width="3cm" />
      	<fo:table-column />
      	<fo:table-body>
  	  		<fo:table-row>
            <fo:table-cell number-rows-spanned="2">
              <fo:block font-family="Courier" font-size="10pt">
                <xsl:apply-templates select="date"/>
              </fo:block>
            </fo:table-cell>
            <fo:table-cell padding-after="3pt">
              <fo:block>
                <xsl:apply-templates select="name" mode="project"/>
              </fo:block>
            </fo:table-cell>
          </fo:table-row>
          <fo:table-row>
            <fo:table-cell>
              <xsl:apply-templates select="description"/>
            </fo:table-cell>
          </fo:table-row>
        </fo:table-body>
      </fo:table>
    </fo:block>
  </xsl:template> 
  -->
  
  <!-- Centres D'interet -->
  <xsl:template match="loisirs">
    <fo:block>
      <xsl:apply-templates select="loisir" />
    </fo:block>
  </xsl:template>
 
  <xsl:template match="loisir">
    <fo:block>
      <fo:table table-layout="fixed" padding-after="6pt">
        <fo:table-column column-width="3cm" />
    		<fo:table-column />
    		<fo:table-body>
	  			<fo:table-row>
        		<fo:table-cell> 
				      <fo:block font-style="italic">
				        <xsl:value-of select="domaine" />
				      </fo:block>
	    			</fo:table-cell>
    	    	<fo:table-cell>
				      <fo:block>
				        <xsl:apply-templates select="enumLoisir" />
				      </fo:block>
    	    	</fo:table-cell>
    			</fo:table-row>
      	</fo:table-body>
    	</fo:table>
    </fo:block>
  </xsl:template>
  
  <xsl:template match="enumLoisir">
    <fo:block>
			<xsl:apply-templates />
    </fo:block>
  </xsl:template>
  
  <!-- Divers balises.. -->  
  <xsl:template match="bolded">
    <fo:inline font-weight="bold">
      <xsl:value-of select="."/>   
    </fo:inline>
  </xsl:template>
  
  <xsl:template match="italik">
		<fo:inline font-style="italic">
      <xsl:value-of select="."/>   
    </fo:inline>
  </xsl:template>
  
  <xsl:template match="lien">
			<fo:basic-link color="#232579">
				<xsl:attribute name="external-destination"><xsl:value-of select="@ici"/></xsl:attribute>
				<xsl:value-of select="."/>
			</fo:basic-link>  
  </xsl:template> 
  
  <xsl:template match="latex">
		<xsl:choose>    
			<xsl:when test="latex != 'LaTeX'">
				<xsl:apply-templates select="."/>
			</xsl:when>
			<xsl:otherwise>
				L<fo:inline font-variant="small-caps" padding="0pt 2pt" baseline-shift="super">a</fo:inline>T<fo:inline font-variant="small-caps" padding="0pt 2pt" baseline-shift="sub">e</fo:inline>X					
			</xsl:otherwise>						
		</xsl:choose>   
  </xsl:template>
  
</xsl:stylesheet>
