<data>
	<organization>
		<name>${organizationData.name}</name>
		<address>${organizationData.mainContact.address}</address>
		<web>www.kssp.cz</web>
	</organization>
	<#if participantsData?has_content>
	    <#list participantsData as participant>
	        <@printParticipant participant />
	    </#list>
    </#if>
</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, 'Matka vrhu (nelze změnit)')??>
            <#local fena = ParticipantFunctions.getAssetByFunction(assets, 'Matka vrhu (nelze změnit)')>
        </#if>
        <#if ParticipantFunctions.getAssetByFunction(assets, 'Otec vrhu')??>
            <#local pes = ParticipantFunctions.getAssetByFunction(assets, 'Otec vrhu')>
        </#if>
        <#local stenata = ParticipantFunctions.getRepeatedAssetsByFunction(assets, "Štěně")>
    </#if>
	<participant>
		<breeder>
			<name>${participant.name}</name>
            <#local ownerContact = ParticipantFunctions.getContactByType(contacts, 'Kontaktní adresa')>
			<address><#if ownerContact??>${ownerContact.address}</#if></address>
			<breedingStation>${ParticipantFunctions.getInfoValue(infos, 'Název chovatelské stanice')}</breedingStation>
		</breeder>

		<female>
			<name><#if fena??>${fena.name!""}</#if></name>
			<number><#if fena??>${fena.number!""}</#if></number>
			<breed><#if fena??>${ParticipantFunctions.getAssetAttributeValue(fena.renderedAttributes, 'Plemeno')}</#if></breed>
		</female>
		<male>
			<name><#if pes??>${pes.name!""}</#if></name>
			<number><#if pes??>${pes.number!""}</#if></number>
		</male>
		<litter>${ParticipantFunctions.getInfoValue(infos, 'Vrh')}</litter>
		<litterDate>${ParticipantFunctions.getInfoValue(infos, 'Datum vrhu')}</litterDate>
        <#list 1..15 as x>
            <#assign hasPuppy = false>
            <#if stenata?has_content>
                <#if stenata[x - 1]??>
                    <#assign puppy = stenata[x - 1]>
                    <#assign hasPuppy = true>
                </#if>
            </#if>
	        <#if hasPuppy>
				<puppy>
					<name>${puppy.name!""}</name>
					<number>${puppy.number}</number>
					<chip><#if puppy??>${ParticipantFunctions.getAssetAttributeValue(puppy.renderedAttributes, 'Číslo čipu')}</#if></chip>
					<sex><#if puppy??>${ParticipantFunctions.getAssetAttributeValue(puppy.renderedAttributes, 'Pohlaví')}</#if></sex>
				</puppy>
            </#if>
        </#list>
		<checker>${ParticipantFunctions.getInfoValue(infos, 'Kontrolor vrhu')}</checker>
	</participant>
</#macro>