{% load settings text %}{# A template for encoding an submission.models.Article as JATS 1.2 #}{# Context: `article` `body` `include_declaration` #}{% if include_declaration %}<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE article PUBLIC
            "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.2 20120330//EN"
            "http://jats.nlm.nih.gov/publishing/1.2/JATS-journalpublishing1.dtd">
{% endif %}
{% if validation_error %}<!-- {{ validation_error }} -->{% endif %}
<article
        article-type="{{ article.jats_article_type|default:'research-article' }}"
        dtd-version="1.2"
        xml:lang="{{ article.iso639_1_lang_code }}"
        xmlns:mml="http://www.w3.org/1998/Math/MathML"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <front>
        <journal-meta>
            <journal-id journal-id-type="issn">{{ article.journal.issn }}</journal-id>
            <journal-title-group>
                <journal-title>{{ article.journal.name }}</journal-title>
            </journal-title-group>
            <issn pub-type="epub">{{ article.journal.issn }}</issn>
            <publisher>
                <publisher-name>{{ article.journal|setting:'publisher_name' }}</publisher-name>
            </publisher>
        </journal-meta>
        <article-meta>
            {% if article.get_doi %}
            <article-id pub-id-type="doi">{{ article.get_doi }}</article-id>
            {% endif %}
            <article-id pub-id-type="publisher-id">{{ article.pk }}</article-id>
            <article-categories>
                <subj-group>
                    <subject>{{ article.section.name }}</subject>
                </subj-group>
            </article-categories>
            <title-group>
                <article-title>{{ article.title }}</article-title>
            </title-group>
            <contrib-group>
                {% for item in article.frozen_authors_for_jats_contribs %}
                    {% with author=item.author affiliations=item.affiliations %}
                        <contrib contrib-type="author"{% if author.is_correspondence_author %} corresp="yes"{% endif %}>
                            {% if author.orcid_uri %}
                                <contrib-id contrib-id-type="orcid">{{ author.orcid_uri }}</contrib-id>
                            {% endif %}
                            <name>
                                <surname>{{ author.last_name }}</surname>
                                <given-names>{{ author.given_names }}</given-names>
                            </name>
                            {% if author.is_correspondence_author %}
                                <email>{{ author.author.email }}</email>
                            {% endif %}
                            {% if article.journal|setting:'use_credit' and author.credits.exists %}
                                {% for credit_record in author.credits %}
                                    <role
                                            vocab="credit"
                                            vocab-identifier="https://credit.niso.org/"
                                            vocab-term="{{ credit_record.get_role_display }}"
                                            vocab-term-identifier="{{ credit_record.uri }}"
                                          >{{ credit_record.get_role_display }}</role>
                                {% endfor %}
                            {% endif %}
                            {% for affiliation in affiliations %}
                                <aff>
                                    <institution-wrap>
                                        {% if affiliation.organization.ror_id %}
                                            <institution-id institution-id-type="ROR">
                                                {{ affiliation.organization.uri }}
                                            </institution-id>
                                        {% endif %}
                                        <institution>{{ affiliation.organization.name }}</institution>
                                    </institution-wrap>
                                </aff>
                            {% endfor %}
                        </contrib>
                    {% endwith %}
                {% endfor %}
            </contrib-group>

            {% if article.competing_interests or article.correspondence_author %}
                <author-notes>
                    {% if article.competing_interests %}
                        <fn fn-type="com">
                            <p>{{ article.competing_interests }}</p>
                        </fn>
                    {% endif %}
                    {% if article.correspondence_author %}
                        <corresp id="cor1">Corresponding Author: <email
                          xlink:href="mailto:{{ article.correspondence_author.email }}"
                        >{{ article.correspondence_author.email }}</email></corresp>
                    {% endif %}
                </author-notes>
            {% endif %}
            {% if article.date_published %}
            <pub-date date-type="pub" iso-8601-date="{{ article.date_published|date:"Y-m-d" }}" publication-format="electronic">
                <day>{{ article.date_published|date:"d" }}</day>
                <month>{{ article.date_published|date:"m" }}</month>
                <year>{{ article.date_published|date:"Y" }}</year>
            </pub-date>
            {% endif %}

            <volume seq="{{ article.issue.order }}">{{ article.issue.volume }}</volume>
            <issue>{{ article.issue.issue }}</issue>
            <issue-id>{{ article.issue.pk }}</issue-id>
            {% if article.issue.issue_title %}
            <issue-title xml:lang="en">{{ article.issue.issue_title }}</issue-title>
            {% endif %}
            {% if article.first_page %}
                <fpage>{{ article.first_page }}</fpage>
            {% endif %}
            {% if article.last_page %}
                <lpage>{{ article.last_page }}</lpage>
            {% endif %}
            {% if article.page_numbers %}
                <page-range>{{ article.page_numbers }}</page-range>
            {% endif %}
            {% if total_pages %}
                <counts>
                    <page-count count="{{ article.total_pages }}"/>
                </counts>
            {% endif %}
            {% if not article.first_page and not article.page_numbers %}
                {# This is a fallback page id required by crossref when fpage or page-range is missing #}
                <elocation-id>{{ article.pk }}</elocation-id>
            {% endif %}

            {% if article.date_submitted or article.date_accepted %}
                <history>
                    {% if article.date_submitted %}
                        <date date-type="received" iso-8601-date="{{ article.date_submitted|date:"Y-m-d" }}">
                            <day>{{ article.date_submitted|date:"d" }}</day>
                            <month>{{ article.date_submitted|date:"m" }}</month>
                            <year>{{ article.date_submitted|date:"Y" }}</year>
                        </date>
                    {% endif %}
                    {% if article.date_accepted %}
                        <date date-type="accepted" iso-8601-date="{{ article.date_accepted|date:"Y-m-d" }}">
                            <day>{{ article.date_accepted|date:"d" }}</day>
                            <month>{{ article.date_accepted|date:"m" }}</month>
                            <year>{{ article.date_accepted|date:"Y" }}</year>
                        </date>
                    {% endif %}
                </history>
            {% endif %}

            <permissions>
                <copyright-statement>Copyright: © {{ article.date_published|date:"Y" }} The Author(s)</copyright-statement>
                <copyright-year>{{ article.date_published|date:"Y" }}</copyright-year>
            </permissions>
            <self-uri content-type="text/html" xlink:href="{{ article.url }}"/>
            {% if article.pdfs.exists %}
            <self-uri content-type="application/pdf" xlink:href="{% journal_url 'serve_article_pdf' 'id' article.id %}"/>
            {% endif %}
            <abstract>{{ article.get_clean_abstract }}</abstract>
            {% if article.keywords.exists %}
            <kwd-group xml:lang="en">
                <title>Keywords</title>
                {% for keyword in article.keywords.all %}
                    <kwd>{{ keyword.word }}</kwd>
                {% endfor %}
            </kwd-group>
            {% endif %}

            {% if article.funders.all %}
                <funding-group specific-use="crossref">
                    {% for funder in article.funders.all %}
                        <award-group>
                            <funding-source id="funder-{{ forloop.counter }}">
                                <institution-wrap>
                                    <institution>{{ funder.name }}</institution>
                                    {% if funder.fundref_id %}
                                        <institution-id
                                                institution-id-type="doi"
                                                vocab="open-funder-registry"
                                                vocab-identifier="10.13039/open_funder_registry">
                                            {{ funder.fundref_id }}
                                        </institution-id>
                                    {% endif %}
                                </institution-wrap>
                            </funding-source>
                            {% if funder.funding_id %}
                                <award-id>{{ funder.funding_id }}</award-id>
                            {% endif %}
                        </award-group>
                    {% endfor %}
                </funding-group>
            {% endif %}

        </article-meta>
    </front>
    {% if body %}
    <body> {{ body|safe }} </body>
    {% endif %}
</article>
