<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:hr="http://www.hr-xml.org/3"
 xmlns:ccts="urn:un:unece:uncefact:documentation:1.1"
 xmlns:oa="http://www.openapplications.org/oagis/9"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:europass="http://europass.cedefop.europa.eu/Europass/V2.0" 
 version="1.0"
 exclude-result-prefixes="xsl hr ccts oa xsd">
  <!--
    This file is part of the HR-XML Europass CV application profile.
    Copyright © 2006-2010 - Marc Van Coillie <marc.van.coillie@eife-l.org>
    
    This software is distributed under opensource GNU LGPL License:
    
    HR-XML Europass CV application profile is free software; 
    you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 2.1 of the License, or
    any later version.
    
    HR-XML Europass CV application profile is distributed in the hope that it  be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.
    
    You should have received a copy of the GNU Lesser General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  -->
  <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" indent="yes"/>
  <xsl:template match="/">
    <xsl:processing-instruction name="xml-stylesheet">href="http://europass.cedefop.europa.eu/xml/cv_<xsl:value-of select="translate(//hr:Candidate/attribute::languageCode, '-', '_')"/>_V2.0.xsl" type="text/xsl"</xsl:processing-instruction>
    <europass:learnerinfo 
     xmlns:europass="http://europass.cedefop.europa.eu/Europass/V2.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://europass.cedefop.europa.eu/Europass/V2.0 http://europass.cedefop.europa.eu/xml/EuropassSchema_V2.0.xsd">
      <xsl:attribute name="locale">
        <xsl:value-of select="translate(/hr:Candidate/attribute::languageCode, '-', '_')"/>      
      </xsl:attribute>
      <docinfo>
<xsl:choose>
  <xsl:when test="/hr:Candidate/hr:DataCapture/hr:FormattedDateTime!=''">
  <issuedate>
    <xsl:value-of select="/hr:Candidate/hr:DataCapture/hr:FormattedDateTime"/>
  </issuedate>
  </xsl:when>
          <xsl:otherwise>
            <issuedate>notKnown</issuedate>
          </xsl:otherwise>
        </xsl:choose>
        <xsdversion>V2.0</xsdversion>
        <comment>Automatically generated Europass CV from HR-XML Europass CV AP v2.0.3.0 using EIfEL XSLT v2.0.3.0, please report any bug to marc.van.coillie@eife-l.org</comment>
      </docinfo>
      <prefs>
          <xsl:call-template name="prefs">
          </xsl:call-template>
        </prefs>
          
      <identification>
              <firstname>
                <xsl:value-of select="/hr:Candidate/hr:CandidatePerson/hr:PersonName/oa:GivenName"/>                
              </firstname>
              <lastname>
                <xsl:value-of select="/hr:Candidate/hr:CandidatePerson/hr:PersonName/FamilyName"/>
              </lastname>
              
              <contactinfo>
                <xsl:for-each select="/hr:Candidate/hr:CandidatePerson/hr:Communication/hr:Address">
                  <address>
                    <addressLine>
                      <xsl:value-of select="oa:AddressLine"/>
                    </addressLine>
                    <municipality>
                      <xsl:value-of select="oa:CityName"/>
                    </municipality>
                    <postalCode>
                      <xsl:value-of select="oa:PostalCode"/> 
                    </postalCode>
                    <country>
                      <code><xsl:value-of select="hr:CountryCode"/></code>
                      <label><xsl:value-of select="hr:UserArea/europass:CountryLabel"/></label>
                    </country>
                  </address>
                </xsl:for-each>
                
                <telephone>
                  <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:Communication/hr:ChannelCode='Telephone'">
                    <xsl:value-of select="/hr:Candidate/hr:CandidatePerson/hr:Communication[hr:ChannelCode='Telephone']/oa:DialNumber"/>
                </xsl:if>
                </telephone>
                
                <fax>
                  <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:Communication/hr:ChannelCode='Fax'">
                    <xsl:value-of select="/hr:Candidate/hr:CandidatePerson/hr:Communication[hr:ChannelCode='Fax']/oa:DialNumber"/>
                  </xsl:if>
                </fax>
                
                <mobile>
                  <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:Communication/hr:ChannelCode='MobileTelephone'">
                    <xsl:value-of select="/hr:Candidate/hr:CandidatePerson/hr:Communication[hr:ChannelCode='MobileTelephone']/oa:DialNumber"/>
                  </xsl:if>
                </mobile>
                
                <email>
                  <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:Communication/hr:ChannelCode='Email'">
                    <xsl:value-of select="/hr:Candidate/hr:CandidatePerson/hr:Communication[hr:ChannelCode='Email']/oa:DialNumber"/>
                  </xsl:if>
                </email>
              </contactinfo>
              
              <demographics>
                <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:BirthDate">
                  <birthdate>
                    <xsl:value-of select="/hr:Candidate/hr:CandidatePerson/hr:BirthDate"/>
                  </birthdate>
                </xsl:if>
                
                 <xsl:choose>
                   <xsl:when test="/hr:Candidate/hr:CandidatePerson/hr:GenderCode = 'Male'">
                     <gender>M</gender>
                   </xsl:when>
                   <xsl:when test="/hr:Candidate/hr:CandidatePerson/hr:GenderCode = 'Female'">
                     <gender>F</gender>
                   </xsl:when>
                   <xsl:when test="/hr:Candidate/hr:CandidatePerson/hr:GenderCode = 'Other'">
                     <gender>NA</gender>
                   </xsl:when>
                  </xsl:choose>
                                  
                <xsl:for-each select="/hr:Candidate/hr:CandidatePerson/hr:NationalityCode">
                  <xsl:variable name="theposition"><xsl:value-of select="position()" /></xsl:variable>
                  <nationality>
                    <code>
                      <xsl:value-of select="."/>
                    </code>
                    <label>
                      <xsl:value-of select="../hr:UserArea/europass:NationalityLabel[$theposition+0]"/>
                    </label>
                  </nationality>
                </xsl:for-each>
              </demographics>

        <xsl:if test="/hr:Candidate/hr:CandidateProfile/hr:Attachment/hr:AttachmentXPath='/Candidate/CandidatePerson'">
            <xsl:element name="photo">
<!--
  <xsl:attribute name="type"><xsl:value-of select="translate(/hr:Candidate/hr:CandidateProfile/hr:Attachment[hr:AttachmentXPath='/Candidate/CandidatePerson']/oa:EmbeddedData/attribute::mimeCode, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/></xsl:attribute>
  -->
              <xsl:attribute name="type">JPEG</xsl:attribute>
              <xsl:value-of select="/hr:Candidate/hr:CandidateProfile/hr:Attachment[hr:AttachmentXPath='/Candidate/CandidatePerson']/oa:EmbeddedData"/>
            </xsl:element>
        </xsl:if>
        
      
      </identification>
              
      <xsl:choose>
          <xsl:when test="/hr:Candidate/hr:CandidateProfile/hr:CandidatePositionPreferences/hr:JobCategory/oa:Description">
        <application>
          <code><xsl:value-of select="/hr:Candidate/hr:CandidateProfile/hr:CandidatePositionPreferences/hr:JobCategory/hr:JobCategoryCode"/>
          </code>
          <label><xsl:value-of select="/hr:Candidate/hr:CandidateProfile/hr:CandidatePositionPreferences/hr:JobCategory/oa:Description"/>
          </label>
        </application>
      </xsl:when>
      </xsl:choose>
      
      <xsl:if test="/hr:Candidate/hr:CandidateProfile/hr:EmploymentHistory/hr:EmployerHistory">
              <workexperiencelist>
                <xsl:for-each select="/hr:Candidate/hr:CandidateProfile/hr:EmploymentHistory/hr:EmployerHistory">
                  <workexperience>
                    <period>
                      <from>
                        <xsl:for-each select="hr:EmploymentPeriod/hr:StartDate/hr:FormattedDateTime">
                          <xsl:call-template name="transform-date">
                            <xsl:with-param name="node">
                              <xsl:copy-of select="."/>
                            </xsl:with-param>
                          </xsl:call-template>
                        </xsl:for-each>
                      </from>
                      <to>
                        <xsl:for-each select="hr:EmploymentPeriod/hr:EndDate/hr:FormattedDateTime">
                          <xsl:call-template name="transform-date">
                            <xsl:with-param name="node">
                              <xsl:copy-of select="."/>
                            </xsl:with-param>
                          </xsl:call-template>
                        </xsl:for-each>
                      </to>
                    </period>
                    <xsl:choose>
                      <xsl:when test="hr:PositionHistory/hr:JobCategoryCode">
                        <position>
                          <code><xsl:value-of select="hr:PositionHistory/hr:JobCategoryCode"/></code>
                          <label><xsl:value-of select="hr:PositionHistory/hr:PositionTitle"/></label>
                        </position>
                      </xsl:when>
                      <xsl:when test="hr:PositionHistory/hr:PositionTitle">
                        <position>
                          <label><xsl:value-of select="hr:PositionHistory/hr:PositionTitle"/></label>
                        </position>
                      </xsl:when>
                    </xsl:choose>
                    <activities><xsl:value-of select="hr:PositionHistory/oa:Description"/></activities>
                    <employer>
                      <name><xsl:value-of select="hr:OrganizationName"/></name>
                      <address>
                      <addressLine>
                        <xsl:value-of select="hr:OrganizationContact/hr:Communication/hr:Address/oa:AddressLine"/>
                      </addressLine>
                      <municipality>
                        <xsl:value-of select="hr:OrganizationContact/hr:Communication/hr:Address/oa:CityName"/>
                      </municipality>
                      <postalCode>
                        <xsl:value-of select="hr:OrganizationContact/hr:Communication/hr:Address/oa:PostalCode"/> 
                      </postalCode>
                      <country>
                        <code><xsl:value-of select="hr:OrganizationContact/hr:Communication/hr:Address/hr:CountryCode"/></code>
                        <label><xsl:value-of select="hr:OrganizationContact/hr:Communication/hr:Address/hr:UserArea/europass:CountryLabel"/></label>
                      </country>
                    </address>
                    <sector>
                      <code>
                        <xsl:value-of select="hr:IndustryCode"/>
                      </code>
                      <label>
                        <xsl:value-of select="hr:UserArea/europass:IndustryCodeLabel"/>
                      </label>
                    </sector>
                    </employer>
                  </workexperience>
                </xsl:for-each>
              </workexperiencelist>
            </xsl:if>
            
      <xsl:if test="/hr:Candidate/hr:CandidateProfile/hr:EducationHistory/hr:EducationOrganizationAttendance">
              <educationlist>
                <xsl:for-each select="/hr:Candidate/hr:CandidateProfile/hr:EducationHistory/hr:EducationOrganizationAttendance">
                  <education>
                    <period>
                      <from>
                        <xsl:for-each select="hr:AttendancePeriod/hr:StartDate/hr:FormattedDateTime">
                          <xsl:call-template name="transform-date">
                            <xsl:with-param name="node">
                              <xsl:copy-of select="."/>
                            </xsl:with-param>
                          </xsl:call-template>
                          </xsl:for-each>
                      </from>
                      <to>
                        <xsl:for-each select="hr:AttendancePeriod/hr:EndDate/hr:FormattedDateTime">
                          <xsl:call-template name="transform-date">
                            <xsl:with-param name="node">
                              <xsl:copy-of select="."/>
                            </xsl:with-param>
                          </xsl:call-template>
                        </xsl:for-each>
                      </to>
                    </period>
                    <title>
                      <xsl:value-of select="hr:EducationDegree/hr:DegreeName"/>
                    </title>
                    <skills>
                      <xsl:value-of select="hr:EducationDegree/hr:Comment"/>
                    </skills>
                    <organisation>
                        <name>
                          <xsl:value-of select="hr:OrganizationName"/>
                        </name>
                        <address>
                          <addressLine>
                            <xsl:value-of select="hr:OrganizationContact/hr:Communication/hr:Address/oa:AddressLine"/>
                          </addressLine>
                          <municipality>
                            <xsl:value-of select="hr:OrganizationContact/hr:Communication/hr:Address/oa:CityName"/>
                          </municipality>
                          <postalCode>
                            <xsl:value-of select="hr:OrganizationContact/hr:Communication/hr:Address/oa:PostalCode"/> 
                          </postalCode>
                          <country>
                            <code><xsl:value-of select="hr:OrganizationContact/hr:Communication/hr:Address/hr:CountryCode"/></code>
                            <label><xsl:value-of select="hr:OrganizationContact/hr:Communication/hr:Address/hr:UserArea/europass:CountryLabel"/></label>
                          </country>
                        </address>
                      <type>
                        <xsl:value-of select="hr:UserArea/europass:OrganizationType"/>
                      </type>
                    </organisation>
                    <xsl:choose>
                      <xsl:when test="hr:EducationLevelCode">
                        <level>
                          <code><xsl:value-of select="hr:EducationLevelCode"/></code>
                          <label><xsl:value-of select="hr:UserArea/europass:EducationLevelLabel"/></label>
                        </level>
                      </xsl:when>
                      <xsl:when test="hr:UserArea/europass:EducationLevelLabel">
                        <level>
                          <label><xsl:value-of select="hr:UserArea/europass:EducationLevelLabel"/></label>
                        </level>
                      </xsl:when>
                    </xsl:choose>
                    <xsl:choose>
                      <xsl:when test="hr:EducationDegree/hr:UserArea/europass:DegreeClassification/europass:Id/europass:IdValue/text()!=''">
                        <educationalfield>
                          <code><xsl:value-of select="hr:EducationDegree/hr:UserArea/europass:DegreeClassification/europass:Id/europass:IdValue/text()"/></code>
                          <label><xsl:value-of select="hr:EducationDegree/hr:UserArea/europass:DegreeClassification/europass:Description/text()"/></label>
                        </educationalfield>
                      </xsl:when>
                      <xsl:when test="hr:EducationDegree/hr:UserArea/europass:DegreeClassification/europass:Description">
                        <educationalfield>
                          <label><xsl:value-of select="hr:EducationDegree/hr:UserArea/europass:DegreeClassification/europass:Description"/></label>
                        </educationalfield>
                      </xsl:when>
                    </xsl:choose>
                  </education>
                </xsl:for-each>
              </educationlist>
            </xsl:if>
            
            <languagelist>
              <xsl:for-each select="/hr:Candidate/hr:CandidatePerson/hr:PrimaryLanguageCode">
                <xsl:variable name="theposition"><xsl:value-of select="position()" /></xsl:variable>
                <language xsi:type="europass:mother">
                  <code>
                    <xsl:value-of select="translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
                  </code>
                  <label>
                    <xsl:value-of select="../hr:UserArea/europass:PrimaryLanguageLabel[$theposition+0]"/>
                  </label>
                </language>
              </xsl:for-each>
            
              <xsl:if test="/hr:Candidate/hr:CandidateProfile/hr:PersonQualifications/hr:PersonCompetency/hr:CompetencyID='Europass-LanguageSkills'">
                <xsl:for-each select="/hr:Candidate/hr:CandidateProfile/hr:PersonQualifications/hr:PersonCompetency[hr:CompetencyID='Europass-LanguageSkills']/hr:UserArea/hr:PersonCompetency">
                  <language xsi:type="europass:foreign">
                    <code>
                      <xsl:value-of select="hr:CompetencyID"/>
                      <!-- <xsl:value-of select="hr:CompetencyId/@id"/>  -->
                    </code>
                    <label>
                      <xsl:value-of select="hr:CompetencyEvidence/oa:Description"/>
                    </label>
                    <level>
                      <listening>
                        <xsl:value-of select="translate(hr:UserArea/hr:PersonCompetency[hr:CompetencyID='CEF-Understanding-Listening']/hr:CompetencyEvidence/hr:Score/hr:ScoreText, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
                      </listening>
                      <reading>
                        <xsl:value-of select="translate(hr:UserArea/hr:PersonCompetency[hr:CompetencyID='CEF-Understanding-Reading']/hr:CompetencyEvidence/hr:Score/hr:ScoreText, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
                      </reading>
                      <spokeninteraction>
                        <xsl:value-of select="translate(hr:UserArea/hr:PersonCompetency[hr:CompetencyID='CEF-Speaking-SpokenInteraction']/hr:CompetencyEvidence/hr:Score/hr:ScoreText, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
                      </spokeninteraction>
                      <spokenproduction>
                        <xsl:value-of select="translate(hr:UserArea/hr:PersonCompetency[hr:CompetencyID='CEF-Speaking-SpokenProduction']/hr:CompetencyEvidence/hr:Score/hr:ScoreText, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
                      </spokenproduction>
                      <writing>
                        <xsl:value-of select="translate(hr:UserArea/hr:PersonCompetency[hr:CompetencyID='CEF-Writing']/hr:CompetencyEvidence/hr:Score/hr:ScoreText, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
                      </writing>
                    </level>
                  </language>
                </xsl:for-each>
              </xsl:if>
            </languagelist>
            
            <skilllist>
              <xsl:call-template name="competencySection">
                <xsl:with-param name="name">social</xsl:with-param>
                <xsl:with-param name="title">__(Social skills and competences)</xsl:with-param>
              </xsl:call-template>
              <xsl:call-template name="competencySection">
                <xsl:with-param name="name">organisational</xsl:with-param>
                <xsl:with-param name="title">__(Organisational skills and competences)</xsl:with-param>
              </xsl:call-template>
              <xsl:call-template name="competencySection">
                <xsl:with-param name="name">technical</xsl:with-param>
                <xsl:with-param name="title">__(Technical skills and competences)</xsl:with-param>
              </xsl:call-template>
              <xsl:call-template name="competencySection">
                <xsl:with-param name="name">computer</xsl:with-param>
                <xsl:with-param name="title">__(Computer skills and competences)</xsl:with-param>
              </xsl:call-template>
              <xsl:call-template name="competencySection">
                <xsl:with-param name="name">artistic</xsl:with-param>
                <xsl:with-param name="title">__(Artistic skills and competences)</xsl:with-param>
              </xsl:call-template>
              <xsl:call-template name="competencySection">
                <xsl:with-param name="name">other</xsl:with-param>
                <xsl:with-param name="title">__(Other skills and competences)</xsl:with-param>
              </xsl:call-template>
              <structured-skill xsi:type="europass:driving">
                <xsl:for-each select="/hr:Candidate/hr:CandidateProfile/hr:Licenses/hr:License[hr:LicenseTypeCode='Europass Cedefop Driving Licences']">
                    <drivinglicence>
                      <xsl:value-of select="hr:LicenseID"/>
                    </drivinglicence>
                </xsl:for-each>
              </structured-skill>
            </skilllist>
              
            <misclist>
              <xsl:if test="/hr:Candidate/hr:CandidateProfile/hr:Attachment/hr:AttachmentID='ResumeAdditionalItem'">
                <xsl:for-each select="/hr:Candidate/hr:CandidateProfile/hr:Attachment[hr:AttachmentID='ResumeAdditionalItem']">
                  <misc type="additional">
                    <xsl:value-of select="oa:Description"/>
                  </misc>
                </xsl:for-each>
              </xsl:if>
              
              <xsl:if test="/hr:Candidate/hr:CandidateProfile/hr:Attachment/hr:AttachmentID='ResumeAnnexe'">
                <xsl:for-each select="/hr:Candidate/hr:CandidateProfile/hr:Attachment[hr:AttachmentID='ResumeAnnexe']">
                  <misc type="annexes">
                    <xsl:value-of select="oa:Description"/>
                    <xsl:value-of select="oa:URI"/>
                  </misc>
                </xsl:for-each>
              </xsl:if>
            </misclist>
          
    </europass:learnerinfo>
  </xsl:template>
  

  <xsl:template name="countryName">
    <xsl:param name="code"/>
    <xsl:variable name="value">
      <xsl:value-of select="translate($code, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
    </xsl:variable>
    <xsl:value-of select="$value"/>
  </xsl:template>
  
  <xsl:template name="competencySection">
    <xsl:param name="name"/>
    <xsl:param name="title"/>
    <xsl:if test="/hr:Candidate/hr:CandidateProfile/hr:PersonQualifications/hr:PersonCompetency/hr:CompetencyID=$name">
      <skill>
		<xsl:attribute name="type">
			<xsl:value-of select="$name"/>
		</xsl:attribute>
        <xsl:for-each select="/hr:Candidate/hr:CandidateProfile/hr:PersonQualifications/hr:PersonCompetency[hr:CompetencyID=$name]">
          <xsl:value-of select="hr:CompetencyEvidence/oa:Description"/>
        </xsl:for-each>
      </skill>
    </xsl:if>
  </xsl:template>

  <xsl:template name="transform-date">
    <xsl:param name="node"/>
    <xsl:variable name="year">
      <xsl:value-of select="substring-before($node,'-')"/>
    </xsl:variable>
    <xsl:variable name="month">
      <xsl:value-of select="substring-before(substring-after($node,'-'),'-')"/>
    </xsl:variable>
    <xsl:variable name="day">
      <xsl:value-of select="substring-after(substring-after($node,'-'),'-')"/>
    </xsl:variable>
    <year><xsl:value-of select="$year"/></year>
    <month>--<xsl:value-of select="$month"/></month>
    <day>---<xsl:value-of select="$day"/></day>
  </xsl:template>

  <xsl:template name="prefs">
    <field name="step1.firstName" before="step1.lastName"/>
    <field name="step1.addressInfo" keep="true"/>
    <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:Communication/hr:ChannelCode='Telephone'">
      <field name="step1.telephone" keep="true"/>
     </xsl:if> 
    <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:Communication/hr:ChannelCode='MobileTelephone'">
      <field name="step1.mobile" keep="true"/>
    </xsl:if> 
    <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:Communication/hr:ChannelCode='Fax'">
      <field name="step1.fax" keep="true"/>
    </xsl:if> 
      <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:Communication/hr:ChannelCode='Email'">
        <field name="step1.email" keep="true"/>
    </xsl:if> 
        <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:NationalityCode">
      <field name="step1.nationality" keep="true"/>
    </xsl:if> 
      <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:BirthDate">
        <field name="step1.birthDate" keep="true" format=""/>
    </xsl:if> 
        <xsl:if test="/hr:Candidate/hr:CandidatePerson/hr:GenderCode">
      <field name="step1.gender" keep="true"/>
    </xsl:if> 
      <xsl:if test="/hr:Candidate/hr:CandidateProfile/hr:Attachment/hr:AttachmentXPath='/Candidate/CandidatePerson'">
        <field name="step1.photo" keep="true"/>
    </xsl:if> 
    <field name="step1.application.label" keep="true"/>

    <xsl:if test="/hr:Candidate/hr:CandidateProfile/hr:EmploymentHistory/hr:EmployerHistory">
      <field name="step3List" keep="true" before="step4List"/>
      <xsl:for-each select="/hr:Candidate/hr:CandidateProfile/hr:EmploymentHistory/hr:EmployerHistory">
        <field>
          <xsl:attribute name="name">step3List[<xsl:value-of select="count(preceding::hr:EmployerHistory)"/>].period</xsl:attribute>
          <xsl:attribute name="format">/numeric/long</xsl:attribute>
        </field>
        <field>
          <xsl:attribute name="name">step3List[<xsl:value-of select="count(preceding::hr:EmployerHistory)"/>].position.label</xsl:attribute>
          <xsl:attribute name="keep">true</xsl:attribute>
        </field>
        <field>
          <xsl:attribute name="name">step3List[<xsl:value-of select="count(preceding::hr:EmployerHistory)"/>].activities</xsl:attribute>
          <xsl:attribute name="keep">true</xsl:attribute>
        </field>
        <field>
          <xsl:attribute name="name">step3List[<xsl:value-of select="count(preceding::hr:EmployerHistory)"/>].company.name</xsl:attribute>
          <xsl:attribute name="keep">true</xsl:attribute>
        </field>
        <field>
          <xsl:attribute name="name">step3List[<xsl:value-of select="count(preceding::hr:EmployerHistory)"/>].company.addressInfo</xsl:attribute>
          <xsl:attribute name="keep">true</xsl:attribute>
        </field>
        <field>
          <xsl:attribute name="name">step3List[<xsl:value-of select="count(preceding::hr:EmployerHistory)"/>].company.sector.label</xsl:attribute>
          <xsl:attribute name="keep">true</xsl:attribute>
        </field>
      </xsl:for-each>
    </xsl:if>
    <xsl:if test="/hr:Candidate/hr:CandidateProfile/hr:EducationHistory/hr:EducationOrganizationAttendance">
      <field name="step4List" keep="true"/>
      <xsl:for-each select="/hr:Candidate/hr:CandidateProfile/hr:EducationHistory/hr:EducationOrganizationAttendance">
        <!-- 
          <xsl:value-of select="count(preceding::hr:SchoolOrInstitution)"/>
          <field name="step4List[1].period" format="/numeric/long"/>
        -->
        <field>
          <xsl:attribute name="name">step4List[<xsl:value-of select="count(preceding::hr:EducationOrganizationAttendance)"/>].period</xsl:attribute>
          <xsl:attribute name="format">/numeric/long</xsl:attribute>
        </field>
        <field>
          <xsl:attribute name="name">step4List[<xsl:value-of select="count(preceding::hr:EducationOrganizationAttendance)"/>].title</xsl:attribute>
          <xsl:attribute name="keep">true</xsl:attribute>
        </field>
        <field>
          <xsl:attribute name="name">step4List[<xsl:value-of select="count(preceding::hr:EducationOrganizationAttendance)"/>].skills</xsl:attribute>
          <xsl:attribute name="keep">true</xsl:attribute>
        </field>
        <field>
          <xsl:attribute name="name">step4List[<xsl:value-of select="count(preceding::hr:EducationOrganizationAttendance)"/>].educationalOrg.name</xsl:attribute>
          <xsl:attribute name="keep">true</xsl:attribute>
        </field>
        <field>
          <xsl:attribute name="name">step4List[<xsl:value-of select="count(preceding::hr:EducationOrganizationAttendance)"/>].educationalOrg.addressInfo</xsl:attribute>
          <xsl:attribute name="keep">true</xsl:attribute>
        </field>
        <field>
          <xsl:attribute name="name">step4List[<xsl:value-of select="count(preceding::hr:EducationOrganizationAttendance)"/>].level.label</xsl:attribute>
          <xsl:attribute name="keep">true</xsl:attribute>
        </field>
      </xsl:for-each>
    </xsl:if>  
    <field name="step5.motherLanguages" keep="true"/>
    <field name="step5.foreignLanguageList" keep="true"/>
    <xsl:if test="/hr:Candidate/hr:CandidateProfile/hr:PersonQualifications/hr:PersonCompetency/hr:CompetencyID='Europass-LanguageSkills'">
      <xsl:for-each select="/hr:Candidate/hr:CandidateProfile/hr:PersonQualifications/hr:PersonCompetency[hr:CompetencyID='Europass-LanguageSkills']/hr:UserArea/hr:PersonCompetency">
        <field>
          <xsl:attribute name="name">step5.foreignLanguageList[<xsl:value-of select="position()-1"/>]</xsl:attribute>
<!-- <xsl:attribute name="name">step5.foreignLanguageList[<xsl:value-of select="count(preceding::hr:Competency[@description='CEF']/hr:Competency)"/>]</xsl:attribute>
-->          
          <xsl:attribute name="keep">true</xsl:attribute>
        </field>
      </xsl:for-each>
    </xsl:if>          
    <field name="step6.socialSkills" keep="true"/>
    <field name="step6.organisationalSkills" keep="true"/>
    <field name="step6.technicalSkills" keep="true"/>
    <field name="step6.computerSkills" keep="true"/>
    <field name="step6.artisticSkills" keep="true"/>
    <field name="step6.otherSkills" keep="true"/>
    <field name="step6.drivingLicences" keep="true"/>
    <field name="step7.additionalInfo" keep="true"/>
    <field name="step7.annexes" keep="true"/>
    <field name="grid" keep="false"/>
  </xsl:template>
  
</xsl:stylesheet>
