<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://ns.hr-xml.org/2007-04-15"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:europass="http://europass.cedefop.europa.eu/Europass/V1.2"
    exclude-result-prefixes="europass">
    <!--
This file is part of the HR-XML Europass CV application profile.
Copyright © 2006-2008 - 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" indent="yes"/>
    <xsl:template match="//europass:learnerinfo">
        
        <xsl:element name="Candidate">
            <xsl:attribute name="xml:lang">
                <xsl:value-of select="translate(//europass:learnerinfo/attribute::locale, '_', '-')"/>
            </xsl:attribute>
            <xsl:attribute name="xsi:schemaLocation">http://ns.hr-xml.org/2007-04-15 http://ns.hr-xml.org/2_5/HR-XML-2_5/SEP/Candidate.xsd</xsl:attribute>
         
            <xsl:element name="CandidateProfile">
                <xsl:element name="ProfileName">
                    <xsl:value-of select="docinfo/comment/text()"/> 
                    This HR-XML CV has been automatically transformed from Europass CV to HR-XML Europass CV AP v1.2.0 by EIfEL XSLT v1.2.0, please report any bug to marc.van.coillie@eife-l.org
                </xsl:element>
                <xsl:element name="PersonalData">
                    <PersonDescriptors>
                        <DemographicDescriptors>
                                <xsl:if test="identification/demographics/nationality/text()!=''">
                                <Nationality>
                                    <xsl:value-of select="identification/demographics/nationality/code"/>
                                </Nationality>
                            </xsl:if>
                            <xsl:for-each select="languagelist/language[@type='mother']">
                                <PrimaryLanguage>
                                <xsl:value-of select="code"/>
                            </PrimaryLanguage>
                            </xsl:for-each>     
                        </DemographicDescriptors>
                        <BiologicalDescriptors>
                            <xsl:if test="identification/demographics/birthdate/text()!=''">
                                <DateOfBirth>
                                        <xsl:value-of select="identification/demographics/birthdate/text()"/>
                                </DateOfBirth>
                            </xsl:if>
                            <xsl:if test="identification/demographics/gender/text()!=''">
                                <GenderCode>
                                    <xsl:if test="identification/demographics/gender/text()='M'">1</xsl:if>
                                    <xsl:if test="identification/demographics/gender/text()='F'">2</xsl:if>
                                </GenderCode>
                            </xsl:if>
                        </BiologicalDescriptors>
                        <xsl:if test="identification/photo/text()!=''">
                            <SupportingMaterials>
                                <xsl:element name="AttachmentReference">
                                    <xsl:attribute name="mimeType">image/<xsl:value-of select="translate(identification/photo/attribute::type, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/></xsl:attribute>
                                </xsl:element>
                                <xsl:element name="Description">
                                        <xsl:value-of select="identification/photo"/>
                                </xsl:element>
                            </SupportingMaterials>
                        </xsl:if>
                    </PersonDescriptors>
                </xsl:element>
            </xsl:element>
            
            <Resume>

                <StructuredXMLResume>

                    <ContactInfo>
                        <PersonName>
                            <FormattedName>
                                <xsl:value-of select="identification/firstname/text()"/>    
                                <xsl:text disable-output-escaping="yes"> </xsl:text>
                                <xsl:value-of select="identification/lastname/text()"/>
                            </FormattedName>
                            <GivenName>
                                <xsl:value-of select="identification/firstname/text()"/>    
                            </GivenName>
                            <FamilyName>
                                <xsl:value-of select="identification/lastname/text()"/>
                            </FamilyName>
                        </PersonName>
                        <ContactMethod>
                            <xsl:if test="identification/contactinfo/telephone/text()!=''">
                                    <Telephone>
                                        <FormattedNumber>
                                            <xsl:value-of select="identification/contactinfo/telephone/text()"/>     
                                        </FormattedNumber>
                                    </Telephone>
                            </xsl:if>
                            <xsl:if test="identification/contactinfo/mobile/text()!=''">
                                <Mobile>
                                    <FormattedNumber>
                                        <xsl:value-of select="identification/contactinfo/mobile/text()"/>     
                                    </FormattedNumber>
                                </Mobile>
                            </xsl:if>
                            <xsl:if test="identification/contactinfo/fax/text()!=''">
                                    <Fax>
                                        <FormattedNumber>
                                            <xsl:value-of select="identification/contactinfo/fax/text()"/>     
                                        </FormattedNumber>
                                    </Fax>
                            </xsl:if>
                            <xsl:if test="identification/contactinfo/email/text()!=''">
                                    <InternetEmailAddress>
                                        <xsl:value-of select="identification/contactinfo/email/text()"/>     
                                    </InternetEmailAddress>
                            </xsl:if>
                            <PostalAddress>
                                <CountryCode>
                                    <xsl:value-of select="identification/contactinfo/address/country/code"/>     
                                </CountryCode>
                                <PostalCode>
                                    <xsl:value-of select="identification/contactinfo/address/postalCode"/>     
                                </PostalCode>
                                <Municipality>
                                    <xsl:value-of select="identification/contactinfo/address/municipality"/>     
                                </Municipality>
                                <DeliveryAddress>
                                    <AddressLine>
                                    <xsl:value-of select="identification/contactinfo/address/addressLine"/>     
                                    </AddressLine>
                                </DeliveryAddress>
                            </PostalAddress>
                        </ContactMethod>
                    </ContactInfo>

                <Objective>
                    <xsl:value-of select="application/text()"/>     
                </Objective>
                
                <EmploymentHistory>
                    <xsl:for-each select="workexperiencelist/workexperience">
                        <EmployerOrg>
                            <EmployerOrgName>
                                <xsl:value-of select="employer/text()"/>     
                            </EmployerOrgName>
                            <PositionHistory>
                                <Title>
                                    <xsl:value-of select="position/text()"/>     
                                </Title>
                                <OrgName>
                                    <OrganizationName>
                                        <xsl:value-of select="employer/text()"/>     
                                    </OrganizationName>
                                </OrgName>
                                <OrgIndustry primaryIndicator="true">
                                    <IndustryDescription>
                                        <xsl:value-of select="sector/text()"/>     
                                    </IndustryDescription>
                                </OrgIndustry>
                                <Description>
                                    <xsl:value-of select="activities/text()"/>     
                                </Description>
                                <StartDate>
                                    <AnyDate>
                                        <xsl:value-of select="period/from/year/text()"/>     
                                        <xsl:value-of select="substring(period/from/month/text(),2)"/>     
                                        <xsl:value-of select="substring(period/from/day/text(),3)"/>     
                                    </AnyDate>
                                </StartDate>
                                <xsl:if test="period/to/year/text()!=''">
                                    <EndDate>
                                        <AnyDate>
                                            <xsl:value-of select="period/to/year/text()"/>     
                                            <xsl:value-of select="substring(period/to/month/text(),2)"/>     
                                            <xsl:value-of select="substring(period/to/day/text(),3)"/>     
                                        </AnyDate>
                                    </EndDate>
                                </xsl:if>
                            </PositionHistory>
                        </EmployerOrg>
                    </xsl:for-each>     
                </EmploymentHistory>
                
                <EducationHistory>
                    <xsl:for-each select="educationlist/education">
                        <SchoolOrInstitution schoolType="">
                            <School>
                                <SchoolName>
                                    <xsl:value-of select="organisation/text()"/>     
                                </SchoolName>
                            </School>
                            <Degree>
                                <DegreeName>
                                    <xsl:value-of select="title/text()"/>     
                                </DegreeName>
                                <DatesOfAttendance>
                                    <StartDate>
                                        <AnyDate>
                                            <xsl:value-of select="period/from/year/text()"/>     
                                            <xsl:value-of select="substring(period/from/month/text(),2)"/>     
                                            <xsl:value-of select="substring(period/from/day/text(),3)"/>
                                        </AnyDate>
                                    </StartDate>
                                    <xsl:if test="period/to/year/text()!=''">
                                        <EndDate>
                                            <AnyDate>
                                                <xsl:value-of select="period/to/year/text()"/>     
                                                <xsl:value-of select="substring(period/to/month/text(),2)"/>     
                                                <xsl:value-of select="substring(period/to/day/text(),3)"/>     
                                            </AnyDate>
                                        </EndDate>
                                    </xsl:if>
                                </DatesOfAttendance>
                                <xsl:if test="skills/text()!=''">
                                    <xsl:element name="Comments">
                                        <xsl:value-of select="skills/text()"/>
                                    </xsl:element>                          
                                </xsl:if>
                                <xsl:if test="level/text()!=''">
                                            <DegreeClassification>
                                                <Id idOwner="Europass">
                                                    <IdValue>LevelClassification</IdValue>
                                                </Id>
                                                <Description>
                                                <xsl:value-of select="level/text()"/>
                                            </Description>
                                        </DegreeClassification>
                                </xsl:if>
                            </Degree>
                        </SchoolOrInstitution>
                    </xsl:for-each>     
                </EducationHistory>
                
                <xsl:element name="Qualifications">

                    <Competency description="CEF" name="Europass-LanguageSkills">
                        <TaxonomyId idOwner="CEF" description="Common European Framework"
                            id="http://europass.cedefop.europa.eu/Competencies/CEF-main.xml" />
                        <xsl:for-each select="languagelist/language[@type='foreign']">
                            <xsl:element name="Competency">
                            <xsl:attribute name="name">
                                <xsl:value-of select="code"/>
                            </xsl:attribute>
                            <xsl:attribute name="description">
                                <xsl:value-of select="label"/>
                             </xsl:attribute>
                            <xsl:element name="CompetencyId">
                            <xsl:attribute name="id">
                                <xsl:value-of select="code"/>
                            </xsl:attribute>
                                <xsl:attribute name="idOwner">CEF</xsl:attribute>
                            </xsl:element>                          
                            <!--  <TaxonomyId idOwner="Europass" description="Europass-CV-CEF" id="http://profiles.eife-l.org/europass/Europass-CEF.xml"/>
-->                        
                            <Competency name="CEF-Writing">
                                <CompetencyId id="CEF-Writing" idOwner="CEF" />
                                <CompetencyEvidence typeId="self-assessment-europassCV">
                                    <xsl:element name="EvidenceId">
                                        <xsl:attribute name="idOwner">CEF</xsl:attribute>
                                        <xsl:attribute name="description">Common European Framework</xsl:attribute>
                                        <xsl:attribute name="id">http://europass.cedefop.europa.eu/Competencies/CEF-Writing-<xsl:value-of select="translate(level/writing/text(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>.xml</xsl:attribute>
                                    </xsl:element>                          
                                    <StringValue description="Level: A1, A2, B1, B2, C1, C2" maxValue="C2"
                                        minValue="A1">
                                        <xsl:value-of select="translate(level/writing/text(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
                                    </StringValue>
                                </CompetencyEvidence>
                                </Competency>
                                
                                <Competency name="CEF-Speaking-SpokenInteraction">
                                    <CompetencyId id="CEF-Speaking-SpokenInteraction" idOwner="CEF" />
                                    <CompetencyEvidence typeId="self-assessment-europassCV">
                                        <xsl:element name="EvidenceId">
                                            <xsl:attribute name="idOwner">CEF</xsl:attribute>
                                            <xsl:attribute name="description">Common European Framework</xsl:attribute>
                                            <xsl:attribute name="id">http://europass.cedefop.europa.eu/Competencies/CEF-Speaking-SpokenInteraction-<xsl:value-of select="translate(level/spokeninteraction/text(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>.xml</xsl:attribute>
                                        </xsl:element>                          
                                        <StringValue description="Level: A1, A2, B1, B2, C1, C2" maxValue="C2"
                                            minValue="A1">
                                            <xsl:value-of select="translate(level/spokeninteraction/text(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
                                        </StringValue>
                                    </CompetencyEvidence>
                                    </Competency>
                                    
                            <Competency name="CEF-Speaking-SpokenProduction">
                                <CompetencyId id="CEF-Speaking-SpokenProduction" idOwner="CEF" />
                                <CompetencyEvidence typeId="self-assessment-europassCV">
                                    <xsl:element name="EvidenceId">
                                        <xsl:attribute name="idOwner">Europass-CV</xsl:attribute>
                                        <xsl:attribute name="description">Common European Framework</xsl:attribute>
                                        <xsl:attribute name="id">http://europass.cedefop.europa.eu/Competencies/CEF-Speaking-SpokenProduction-<xsl:value-of select="translate(level/spokenproduction/text(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>.xml</xsl:attribute>
                                    </xsl:element>                          
                                    <StringValue description="Level: A1, A2, B1, B2, C1, C2" maxValue="C2"
                                        minValue="A1">
                                        <xsl:value-of select="translate(level/spokenproduction/text(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
                                    </StringValue>
                                </CompetencyEvidence>
                            </Competency>
                            
                            <Competency name="CEF-Understanding-Reading">
                                <CompetencyId id="CEF-Understanding-Reading" idOwner="CEF" />
                                <CompetencyEvidence typeId="self-assessment-europassCV">
                                    <xsl:element name="EvidenceId">
                                        <xsl:attribute name="idOwner">Europass-CV</xsl:attribute>
                                        <xsl:attribute name="description">Common European Framework</xsl:attribute>
                                        <xsl:attribute name="id">http://europass.cedefop.europa.eu/Competencies/CEF-Understanding-Reading-<xsl:value-of select="translate(level/reading/text(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>.xml</xsl:attribute>
                                    </xsl:element>                          
                                    <StringValue description="Level: A1, A2, B1, B2, C1, C2" maxValue="C2"
                                        minValue="A1">
                                        <xsl:value-of select="translate(level/reading/text(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
                                    </StringValue>
                                </CompetencyEvidence>
                            </Competency>
                            
                            <Competency name="CEF-Understanding-Listening">
                                <CompetencyId id="CEF-Understanding-Listening" idOwner="CEF" />
                                <CompetencyEvidence typeId="self-assessment-europassCV">
                                    <xsl:element name="EvidenceId">
                                        <xsl:attribute name="idOwner">Europass-CV</xsl:attribute>
                                        <xsl:attribute name="description">Common European Framework</xsl:attribute>
                                        <xsl:attribute name="id">http://europass.cedefop.europa.eu/Competencies/CEF-Understanding-Listening-<xsl:value-of select="translate(level/listening/text(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>.xml</xsl:attribute>
                                    </xsl:element>                          
                                    <StringValue description="Level: A1, A2, B1, B2, C1, C2" maxValue="C2"
                                        minValue="A1">
                                        <xsl:value-of select="translate(level/listening/text(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
                                    </StringValue>
                                </CompetencyEvidence>
                            </Competency>
                            
                        </xsl:element>                          
                        </xsl:for-each>     
                    </Competency>
                    
                    <Competency description="List of Skills from Europass CV" name="Europass-CV-SkillsList">
                        <TaxonomyId idOwner="Europass" description="Europass CV Skills" 
                            id="http://europass.cedefop.europa.eu/Competencies/Europass-Skills-main.xml"/>
    
                    <xsl:element name="Competency">
                        <xsl:attribute name="name">social</xsl:attribute>
                        <xsl:attribute name="description">
                            <xsl:value-of select="skilllist/skill[@type='social']/text()"/>
                        </xsl:attribute>
                        <TaxonomyId id="http://europass.cedefop.europa.eu/Competencies/Europass-Skills-Social.xml" idOwner="Europass" description="Europass-CV-Skills" />
                    </xsl:element>
                
                <xsl:element name="Competency">
                    <xsl:attribute name="name">organisational</xsl:attribute>
                    <xsl:attribute name="description">
                        <xsl:value-of select="skilllist/skill[@type='organisational']/text()"/>
                    </xsl:attribute>
                    <TaxonomyId id="http://europass.cedefop.europa.eu/Competencies/Europass-Skills-Organisational.xml" idOwner="Europass" description="Europass-CV-Skills" />
                </xsl:element>

                    <xsl:element name="Competency">
                        <xsl:attribute name="name">technical</xsl:attribute>
                        <xsl:attribute name="description">
                            <xsl:value-of select="skilllist/skill[@type='technical']/text()"/>
                        </xsl:attribute>
                        <TaxonomyId id="http://europass.cedefop.europa.eu/Competencies/Europass-Skills-Technical.xml" idOwner="Europass" description="Europass-CV-Skills" />
                    </xsl:element>

                    <xsl:element name="Competency">
                        <xsl:attribute name="name">computer</xsl:attribute>
                        <xsl:attribute name="description">
                            <xsl:value-of select="skilllist/skill[@type='computer']/text()"/>
                        </xsl:attribute>
                        <TaxonomyId id="http://europass.cedefop.europa.eu/Competencies/Europass-Skills-Computer.xml" idOwner="Europass" description="Europass-CV-Skills" />
                    </xsl:element>
                    
                    <xsl:element name="Competency">
                        <xsl:attribute name="name">artistic</xsl:attribute>
                        <xsl:attribute name="description">
                            <xsl:value-of select="skilllist/skill[@type='artistic']/text()"/>
                        </xsl:attribute>
                        <TaxonomyId id="http://europass.cedefop.europa.eu/Competencies/Europass-Skills-Artistic.xml" idOwner="Europass" description="Europass-CV-Skills" />
                    </xsl:element>
                    
                    <xsl:element name="Competency">
                        <xsl:attribute name="name">driving</xsl:attribute>
                        <xsl:attribute name="description">
                            <xsl:value-of select="skilllist/skill[@type='driving']/text()"/>
                        </xsl:attribute>
                        <TaxonomyId id="http://europass.cedefop.europa.eu/Competencies/Europass-Skills-Driving.xml" idOwner="Europass" description="Europass-CV-Skills" />
                    </xsl:element>

                    <xsl:element name="Competency">
                        <xsl:attribute name="name">other</xsl:attribute>
                        <xsl:attribute name="description">
                            <xsl:value-of select="skilllist/skill[@type='other']/text()"/>
                        </xsl:attribute>
                        <TaxonomyId id="http://europass.cedefop.europa.eu/Competencies/Europass-Skills-Other.xml" idOwner="Europass" description="Europass-CV-Skills" />
                    </xsl:element>
                    </Competency>
                    
                </xsl:element>

                <ResumeAdditionalItems>
                    
                    <ResumeAdditionalItem>
                        <Description>
                            <xsl:value-of select="misclist/misc[@type='additional']/text()"/>
                        </Description>
                    </ResumeAdditionalItem>
                </ResumeAdditionalItems>

                    <SupportingMaterials>
                    <AttachmentReference>
                    </AttachmentReference>
                    <Description>
                        <xsl:value-of select="misclist/misc[@type='annexes']/text()"/>
                    </Description>
                </SupportingMaterials>  
                
                    <RevisionDate>
                            <xsl:value-of select="/europass:learnerinfo/docinfo/issuedate/text()"/>
                    </RevisionDate>  
                
                </StructuredXMLResume>

            </Resume>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>
