<data>
	<organization>
		<name>${organizationData.name}</name>
		<address>${organizationData.mainContact.address}</address>
	</organization>

    <#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>
			<tattoo><#if dog??>${ParticipantFunctions.getAssetAttributeValue(dog.renderedAttributes, 'Tetovací číslo')}</#if></tattoo>
			<father><#if dog??>${ParticipantFunctions.getAssetAttributeValue(dog.renderedAttributes, 'Otec')}</#if></father>
			<mother><#if dog??>${ParticipantFunctions.getAssetAttributeValue(dog.renderedAttributes, 'Matka')}</#if></mother>

            <#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>