<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>
        <#local jedinec = ParticipantFunctions.getAssetByFunction(assets, 'Jedinec')>
    </#if>

	<participant>
		<jedinec>
			<name><#if jedinec??>${jedinec.name!""}</#if></name>
			<number><#if jedinec??>${jedinec.number!""}</#if></number>
			<chip><#if jedinec??>${ParticipantFunctions.getAssetAttributeValue(jedinec.renderedAttributes, 'Číslo čipu')}</#if></chip>
			<birthday><#if jedinec??>${ParticipantFunctions.getAssetAttributeValue(jedinec.renderedAttributes, 'Datum narození')}</#if></birthday>
			<breed><#if jedinec??>${ParticipantFunctions.getAssetAttributeValue(jedinec.renderedAttributes, 'Plemeno')}</#if></breed>
			<sex><#if jedinec??>${ParticipantFunctions.getAssetAttributeValue(jedinec.renderedAttributes, 'Pohlaví')}</#if></sex>
			<color><#if jedinec??>${ParticipantFunctions.getAssetAttributeValue(jedinec.renderedAttributes, 'Barva')}</#if></color>
			<attachments>
				<puvod><#if jedinec??>${ParticipantFunctions.getAssetAttributeValue(jedinec.renderedAttributes, 'Průkaz původu')}</#if></puvod>
				<postoj><#if jedinec??>${ParticipantFunctions.getAssetAttributeValue(jedinec.renderedAttributes, 'Postoj')}</#if></postoj>
				<portret><#if jedinec??>${ParticipantFunctions.getAssetAttributeValue(jedinec.renderedAttributes, 'Portrét')}</#if></portret>
			</attachments>
			<owner>
				<name>${participant.name}</name>
                <#local ownerContact = ParticipantFunctions.getContactByType(contacts, 'Kontaktní adresa')>
				<address>${ownerContact.address}</address>
                <#local chsContact = ParticipantFunctions.getContactByType(contacts, 'Chovatelská stanice')>
				<chs>${chsContact.name}</chs>
			</owner>
		</jedinec>

		<vystaveno>${ParticipantFunctions.getInfoValue(infos, 'Vystavení')}</vystaveno>

	</participant>

</#macro>