<data>
	<organization>
		<name>${organizationData.nameShort}</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 participantInfo = participantInfos?api.get(participant.id)>
    <#local assets = participantAssets?api.get(participant.id)>
	<#if assets?has_content>
		<#if ParticipantFunctions.getAssetByFunction(assets, 'Fena')??>
	        <#local fena = ParticipantFunctions.getAssetByFunction(assets, 'Fena')>
	    </#if>
		<#if ParticipantFunctions.getAssetByFunction(assets, 'Pes')??>
	        <#local pes = ParticipantFunctions.getAssetByFunction(assets, 'Pes')>
	    </#if>
    </#if>
	<participant>
		<fena>
			<name><#if fena??>${fena.name!""}</#if></name>
			<number><#if fena??>${fena.number!""}</#if></number>
			<birthday><#if fena??>${ParticipantFunctions.getAssetAttributeValue(fena.renderedAttributes, 'Datum narození')}</#if></birthday>
			<owner>
				<name>${participant.name}</name>
                <#local ownerContact = ParticipantFunctions.getContactByType(contacts, 'Kontaktní adresa')>
				<address><#if ownerContact??>${ownerContact.address}</#if></address>
				<email><#if ownerContact??>${ownerContact.emails}</#if></email>
			</owner>
			<lafora><#if fena??>${ParticipantFunctions.getAssetAttributeValue(fena.renderedAttributes, 'Lafora1')}</#if></lafora>
		</fena>

		<pes>
			<name><#if pes??>${pes.name}</#if></name>
			<number><#if pes??>${pes.number}</#if></number>
			<birthday><#if pes??>${ParticipantFunctions.getAssetAttributeValue(pes.renderedAttributes, 'Datum narození')}</#if></birthday>
            <#if pes??>
                <#local maleMembers = assetMembers?api.get(pes.id)![]>
                <#if ParticipantFunctions.getAssetMemberByType(male1Members, 'Majitel')??>
                    <#local maleMemberByType = ParticipantFunctions.getAssetMemberByType(maleMembers, 'Majitel')>
                    <#if maleMemberByType?has_content>
                        <#local maleOwnerContact = ParticipantFunctions.getContactByType(maleMemberByType.contacts, 'Kontaktní adresa')>
                    </#if>
                </#if>
            </#if>
			<owner>
				<name><#if maleMemberByType??>${maleMemberByType.name!""}</#if></name>
				<address><#if maleOwnerContact??>${maleOwnerContact.address}</#if></address>
				<email><#if maleOwnerContact??>${maleOwnerContact.emails}</#if></email>
			</owner>
			<lafora><#if pes??>${ParticipantFunctions.getAssetAttributeValue(pes.renderedAttributes, 'Lafora1')}</#if></lafora>
		</pes>
		<nakryti>${ParticipantFunctions.getInfoValue(participantInfo, 'Nakrytí')}</nakryti>

	</participant>
</#macro>