<?xml version="1.0" encoding="UTF-8"?>
{% block content %}
{% autoescape true %}
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mods="http://www.loc.gov/mods/v3" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-4.xsd"> 
  
<titleInfo>
	<title>{{ data.title|trim|escape }}</title>
</titleInfo>

{% if attribute(data, 'contributor1_given') or attribute(data, 'contributor1_family') %}
<name type="personal">
	<namePart type="given">{{ data.contributor1_given|trim }}</namePart>
	<namePart type="family">{{ data.contributor1_family|trim }}</namePart>
	<role>
		<roleTerm authority="marcrelator" type="text">{{ data.contributor1_role }}</roleTerm>
	</role>
</name>
{% endif %}

{% if attribute(data, 'contributor2_given') or attribute(data, 'contributor2_family') %}
<name type="personal">
	<namePart type="given">{{ data.contributor2_given|trim }}</namePart>
	<namePart type="family">{{ data.contributor2_family|trim }}</namePart>
	<role>
		<roleTerm authority="marcrelator" type="text">{{ data.contributor2_role }}</roleTerm>
	</role>
</name>
{% endif %}

{% if attribute(data, 'contributor3_given') or attribute(data, 'contributor3_family') %}
<name type="personal">
	<namePart type="given">{{ data.contributor3_given|trim }}</namePart>
	<namePart type="family">{{ data.contributor3_family|trim }}</namePart>
	<role>
		<roleTerm authority="marcrelator" type="text">{{ data.contributor3_role }}</roleTerm>
	</role>
</name>
{% endif %}

{% if attribute(data, 'corporatecontributor') %}
<name type="corporate">
	<namePart>{{ data.corporatecontributor|trim }}</namePart>
	<role>
		<roleTerm authority="marcrelator" type="text">{{ data.corporatecontributor_role }}</roleTerm>
	</role>
</name>
{% endif %}

{% if attribute(data, 'corporatedonor') %}
<name type="corporate">
	<namePart>{{ data.corporatedonor|trim }}</namePart>
	<role>
		<roleTerm authority="marcrelator" type="text">Donor</roleTerm>
	</role>
</name>
{% endif %}


{% if attribute(data, 'date_created') or attribute(data, 'date_issued') or attribute(data, 'publisher') or attribute(data, 'publisher_place') %}
<originInfo>
{% if attribute(data, 'date_created') %}
  {% if ('?' not in attribute(data, 'date_created')) and ('circa' not in attribute(data, 'date_created')) and ('[' not in attribute(data, 'date_created'))   %} 
	<dateCreated encoding="w3cdtf" keyDate="yes">{{ data.date_created }}</dateCreated>
  {% endif %}
  {% if '?' in attribute(data, 'date_created') %}
	<dateCreated encoding="w3cdtf" keyDate="yes" qualifier="questionable">{{ data.date_created|trim('?') }}</dateCreated>
  {% endif %}
  {% if 'circa' in attribute(data, 'date_created') %}
	<dateCreated encoding="w3cdtf" keyDate="yes" qualifier="approximate">{{ data.date_created|trim('circa') }}</dateCreated>
  {% endif %}
  {% if '[' in attribute(data, 'date_created') %}
	<dateCreated encoding="w3cdtf" keyDate="yes" qualifier="inferred">{{ data.date_created|trim('[' and ']') }}</dateCreated>
  {% endif %}
{% endif %}
{% if attribute(data, 'date_qualifier') %}
	<dateIssued encoding="w3cdtf" keyDate="yes" qualifier="{{ data.date_qualifier }}">{{ data.date_issued }}</dateIssued>
{% elseif ('?' not in attribute(data, 'date_issued')) and ('circa' not in attribute(data, 'date_issued')) and ('[' not in attribute(data, 'date_issued'))   %} 
	<dateIssued encoding="w3cdtf" keyDate="yes">{{ data.date_issued }}</dateIssued>
{% elseif '?' in attribute(data, 'date_issued') %}
	<dateIssued encoding="w3cdtf" keyDate="yes" qualifier="questionable">{{ data.date_issued|trim('?') }}</dateIssued>
{% elseif 'circa' in attribute(data, 'date_issued') %}
	<dateIssued encoding="w3cdtf" keyDate="yes" qualifier="approximate">{{ data.date_issued|trim('circa') }}</dateIssued>
{% elseif '[' in attribute(data, 'date_issued') %}
	<dateIssued encoding="w3cdtf" keyDate="yes" qualifier="inferred">{{ data.date_issued|trim('[' and ']') }}</dateIssued>
{% endif %}    
{% if attribute(data, 'publisher') %}
	<publisher>{{ data.publisher|trim|escape }}</publisher>
{% endif %} 
{% if attribute(data, 'publisher_place') %}
    <place>
      <placeTerm type="text">{{ data.publisher_place|trim }}</placeTerm>
    </place>
{% endif %} 
</originInfo>
{% endif %}


{% if attribute(data, 'subject_topic') %}
<subject>
	<topic>{{ data.subject_topic|trim }}</topic>
</subject>
{% endif %}
{% if attribute(data, 'subject1_topic') %}
<subject>
	<topic>{{ data.subject1_topic|trim }}</topic>
</subject>
{% endif %}
{% if attribute(data, 'subject2_topic') %}
<subject>
	<topic>{{ data.subject2_topic|trim }}</topic>
</subject>
{% endif %}
{% if attribute(data, 'subject3_topic') %}
<subject>
	<topic>{{ data.subject3_topic|trim }}</topic>
</subject>
{% endif %}
{% if attribute(data, 'subject4_topic') %}
<subject>
	<topic>{{ data.subject4_topic|trim }}</topic>
</subject>
{% endif %}
{% if attribute(data, 'subject5_topic') %}
<subject>
	<topic>{{ data.subject5_topic|trim }}</topic>
</subject>
{% endif %}

{% if attribute(data, 'subject_geographic') %}
<subject>
	<topic>{{ data.subject_geographic|trim }}</topic>
</subject>
{% endif %}

{% if attribute(data, 'physicallocation') or attribute(data, 'URI') %}
<location>
	{% if attribute(data, 'physicallocation') %}
	<physicalLocation>{{ data.physicallocation|trim }}</physicalLocation>
	{% endif %}
	{% if attribute(data, 'uri') %}
	<url>{{ data.uri|trim }}</url>
	{% endif %}
</location>

{% endif %}

{% if attribute(data, 'continent') or attribute(data, 'country') or attribute(data, 'region') or attribute(data, 'state') or attribute(data, 'territory') or attribute(data, 'county') or attribute(data, 'city') or attribute(data, 'citysection') or attribute(data, 'island') or attribute(data, 'area') or attribute(data, 'extraterrestrialarea') %}
<subject>
	<hierarchicalGeographic>
		<continent>{{ data.continent }}</continent>
		<country>{{ data.country }}</country>
		<state>{{ data.state }}</state>
		<territory>{{ data.territory }}</territory>
		<county>{{ data.county }}</county>
		<city>{{ data.city }}</city>
		<citySection>{{ data.citysection }}</citySection>
		<island>{{ data.island }}</island>
		<area>{{ data.area }}</area>
		<extraterrestrialArea>{{ data.extraterrestrialarea }}</extraterrestrialArea>
	</hierarchicalGeographic>
</subject>
{% endif %}

{% if attribute(data, 'coordinates') %}
<subject>
	<cartographics>
		<coordinates>{{ data.coordinates|trim }}</coordinates>
	</cartographics>
</subject> 
{% endif %} 

{% if attribute(data, 'subject_temporal') %}
<subject>
	<temporal>{{ data.subject_temporal|trim }}</temporal>
</subject>
{% endif %}

{% if attribute(data, 'subject1_given') or attribute(data, 'subject1_family') %}
<subject>
	<name type="personal">
		<namePart type="given">{{ data.subject1_given|trim|escape }}</namePart>
		<namePart type="family">{{ data.subject1_family|trim|escape }}</namePart>
		{% if attribute(data, 'subject1_title') %}
		<namePart type="termsOfAddress">{{ data.subject1_title }}</namePart>
		{% endif %}
	</name>
</subject>
{% endif %}
{% if attribute(data, 'subject2_given') or attribute(data, 'subject2_family') %}
<subject>
	<name type="personal">
		<namePart type="given">{{ data.subject2_given|trim|escape }}</namePart>
		<namePart type="family">{{ data.subject2_family|trim|escape }}</namePart>
		{% if attribute(data, 'subject2_title') %}
		<namePart type="termsOfAddress">{{ data.subject2_title }}</namePart>
		{% endif %}
	</name>
</subject>
{% endif %}
{% if attribute(data, 'subject3_given') or attribute(data, 'subject3_family') %}
<subject>
	<name type="personal">
		<namePart type="given">{{ data.subject3_given|trim|escape }}</namePart>
		<namePart type="family">{{ data.subject3_family|trim|escape }}</namePart>
		{% if attribute(data, 'subject3_title') %}
		<namePart type="termsOfAddress">{{ data.subject3_title }}</namePart>
		{% endif %}
	</name>
</subject>
{% endif %}


{% if attribute(data, 'subject_personal_name') %}
{% for subjectname in attribute(data, 'subject_personal_name')|split (';') %}
<subject>
	<name type="personal">
		<namePart>{{ data.subjectname|trim|escape }}</namePart>
	</name>
</subject>
{% endfor %}
{% endif %} 

{% if attribute(data, 'subject_corporate_name') %}
{% for subjectname in attribute(data, 'subject_corporate_name')|split (';') %}
<subject>
	<name type="corporate">
		<namePart>{{ data.subjectname|trim|escape }}</namePart>
	</name>
</subject>
{% endfor %}
{% endif %} 



{% if attribute(data, 'description') %}
<abstract>{{ data.description|trim|escape }}</abstract>
{% endif %} 

{% if attribute(data, 'notes') %}
<note>{{ data.notes|trim|escape }}</note>
{% endif %} 

{% if attribute(data, 'type') %}
{% for type in attribute(data, 'type')|split (';') %}
<typeOfResource>{{ type|trim|lower }}</typeOfResource>
{% endfor %}
{% endif %} 
  
{% if attribute(data, 'genre') %}
<genre authority="{{ data.genre_authority }}">{{ data.genre|trim }}</genre>
{% endif %} 
  
{% if attribute(data, 'extent') or attribute(data, 'form') or attribute(data, 'internetmediatype') or attribute(data, 'digital_origin') %}
<physicalDescription>
	{% if attribute(data, 'form') %}
	<form>{{ data.form|trim }}</form>
	{% endif %} 
	{% if attribute(data, 'extent') %}
    <extent>{{ data.extent|trim }}</extent>
	{% endif %} 
	{% if attribute(data, 'internetmediatype') %}
    <internetMediaType>{{ data.internetmediatype|trim|lower }}</internetMediaType>
    {% endif %}
    {% if attribute(data, 'digital_origin') %}
    <digitalOrigin>{{ data.digital_origin|trim|lower }}</digitalOrigin>
    {% endif %}
</physicalDescription>
{% endif %} 

{% if attribute(data, 'language') %}
{% for language in attribute(data, 'language')|split (';') %}
<language>
	<languageTerm type="text" authority="iso639-2b">{{ data.language|trim }}</languageTerm>
</language>
{% endfor %}
{% endif %} 

{% if attribute(data, 'related_resource') %}
<relatedItem>
	<titleInfo>
		<title>{{ data.related_resource|trim|escape }}</title>
	</titleInfo>
</relatedItem>
{% endif %} 

<relatedItem type="host" displayLabel="Collection">
	<titleInfo>
      <title>{{ data.collection|trim|escape }}</title>
    </titleInfo>
</relatedItem>

{% if attribute(data, 'collection_description') %}  
<relatedItem type="host" displayLabel="Collection">
    <abstract>{{ data.collection_description|trim|escape }}</abstract>
</relatedItem>
{% endif %} 
  
{% if attribute(data, 'rights') %} 
<accessCondition type="use and reproduction">{{ data.rights|trim|escape }}</accessCondition>
{% endif %} 
{% if attribute(data, 'creativecommons_uri') %} 
<accessCondition type="use and reproduction" displayLabel="Creative Commons license">{{ data.creativecommons_uri }}</accessCondition>
{% endif %}
{% if attribute(data, 'rightsstatement') %} 
<accessCondition type="use and reproduction" displayLabel="Rights Statement">{{ data.rightsstatement }}</accessCondition>
{% endif %}
{% if attribute(data, 'owning_institution') %} 
<note type="ownership">{{ data.owning_institution|trim|escape }}</note>
{% endif %}
{% if attribute(data, 'localidentifier') %} 
<identifier type="local">{{ data.localidentifier|trim }}</identifier>
{% endif %}
{% if attribute(data, 'doi') %} 
<identifier type="doi">{{ data.doi }}</identifier>
{% endif %}
{% if attribute(data, 'isbn') %} 
<identifier type="isbn">{{ data.isbn }}</identifier>
{% endif %}

<recordInfo>
	<languageOfCataloging>
		<languageTerm authority="iso639-2b" type="code">eng</languageTerm>
    </languageOfCataloging>
</recordInfo>
</mods>
{% endautoescape %}
{% endblock %}