<data>
    <#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, 'Jedinec')??>
            <#local dog = ParticipantFunctions.getAssetByFunction(assets, 'Jedinec')>
        </#if>
    </#if>
	<participant>
		<dog>
			<name><#if dog??>${dog.name!""}</#if></name>
			<number><#if dog??>${dog.number!""}</#if></number>

			<breed><#if dog??>${ParticipantFunctions.getAssetAttributeValue(dog.renderedAttributes, 'Plemeno')}</#if></breed>
			<sex><#if dog??>${ParticipantFunctions.getAssetAttributeValue(dog.renderedAttributes, 'Pohlaví')}</#if></sex>
			<birthday><#if dog??>${ParticipantFunctions.getAssetAttributeValue(dog.renderedAttributes, 'Datum narození')}</#if></birthday>
			<chip><#if dog??>${ParticipantFunctions.getAssetAttributeValue(dog.renderedAttributes, 'Číslo čipu')}</#if></chip>
			<father><#if dog??>${ParticipantFunctions.getAssetAttributeValue(dog.renderedAttributes, 'Otec')?keep_before(" (")}</#if></father>
			<mother><#if dog??>${ParticipantFunctions.getAssetAttributeValue(dog.renderedAttributes, 'Matka')?keep_before(" (")}</#if></mother>

			<newOwner>${ParticipantFunctions.getInfoValue(infos, 'Jméno majitele')}</newOwner>
			<newOwnerEmail>${ParticipantFunctions.getInfoValue(infos, 'E-mail majitele')}</newOwnerEmail>

            <#if dog??>
                <#local dogMembers = assetMembers?api.get(dog.id)![]>
                <#if ParticipantFunctions.getAssetMemberByType(dogMembers, 'Majitel')??>
                    <#local dogMemberByType = ParticipantFunctions.getAssetMemberByType(dogMembers, 'Majitel')>
                    <#if dogMemberByType?has_content>
                        <#local dogOwnerContact = ParticipantFunctions.getContactByType(dogMemberByType.contacts, 'Kontaktní adresa')>
                    </#if>
                </#if>
            </#if>
			<owner>
				<name><#if dogMemberByType??>${dogMemberByType.name!""}</#if></name>
				<address><#if dogMemberByType??>${dogOwnerContact.address}</#if></address>
			</owner>
		</dog>
	</participant>
</#macro>