<data>
	<organization>
		<name>${organizationData.name}</name>
		<address>www.spic.cz</address>
	</organization>
	<created>${now?string["dd.MM.yyyy"]}</created>
    <#list participantsData as participant>
        <@printParticipant participant />
    </#list>
</data>

<#macro printParticipant participant>
    <#local contacts = participantContacts?api.get(participant.id)>
    <#local infos = participantInfos?api.get(participant.id)>
    <#local assets = participantAssets?api.get(participant.id)>
	<#if assets?has_content>
		<#if ParticipantFunctions.getAssetByFunction(assets, 'Otec vrhu')??>
	        <#local father = ParticipantFunctions.getAssetByFunction(assets, 'Otec vrhu')>
	    </#if>
        <#if ParticipantFunctions.getAssetByFunction(assets, 'Matka vrhu')??>
            <#local mother = ParticipantFunctions.getAssetByFunction(assets, 'Matka vrhu')>
        </#if>
        <#local stenata = ParticipantFunctions.getSpecialSortedAssets(ParticipantFunctions.getRepeatedAssetsByFunction(assets, "Štěně"))>
    </#if>
	<participant>
		<breed>${ParticipantFunctions.getInfoValue(infos, 'Plemeno')}</breed>
		<complexion>${ParticipantFunctions.getInfoValue(infos, 'Ráz')}</complexion>
		<breedingStation>${ParticipantFunctions.getInfoValue(infos, 'Název chovatelské stanice')?html}</breedingStation>
		<birth>${ParticipantFunctions.getInfoValue(infos, 'Datum narození vrhu')}</birth>
		<breeder>
			<name>${participant.name}</name>
            <#local breederContact = ParticipantFunctions.getContactByType(contacts, 'Kontaktní adresa')>
			<address><#if breederContact??>${breederContact.address!""}</#if></address>
			<email><#if breederContact??>${breederContact.emails!""}</#if></email>
			<phone><#if breederContact??>${breederContact.phones!""}</#if></phone>
		</breeder>
		<father>
			<name><#if father??>${father.name?html!""}</#if></name>
			<number><#if father??>${father.number!""}</#if></number>
		</father>
		<mother>
			<name><#if mother??>${mother.name?html!""}</#if></name>
			<number><#if mother??>${mother.number!""}</#if></number>
		</mother>
		<#list 1..12 as x>
            <#assign hasPuppy = false>
			<#if stenata?has_content>
                <#if stenata[x - 1]??>
                    <#assign puppy = stenata[x - 1]>
                    <#assign hasPuppy = true>
                </#if>
            </#if>
			<puppy>
                <number>${x}.</number>
				<name><#if hasPuppy>${puppy.name?html!""}</#if></name>
				<sex>
                    <#if hasPuppy>
                        <#assign sex = ParticipantFunctions.getAssetAttributeValue(puppy.renderedAttributes, 'Pohlaví')>
                        <#if sex??>
                            ${sex?cap_first[0..0]}
                        </#if>
                    </#if>
				</sex>
				<color><#if hasPuppy>${ParticipantFunctions.getAssetAttributeValue(puppy.renderedAttributes, 'Barva')?html}</#if></color>

			</puppy>
		</#list>
	</participant>
</#macro>