View stylesheet

XML schema http://dd.eionet.europa.eu/v2/dataset/3426/schema-dst-3426.xsd
Output type HTML
Description Invasive Alien Species Report - HTML Preview
XSL file ias_transform.xsl (Last modified: 31 May 2019 15:29 )
<xsl:stylesheet xpath-default-namespace="http://dd.eionet.europa.eu/namespaces/884"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:local="http://local"
        version="2.0" exclude-result-prefixes="xml">

    <xsl:variable name="labels" select="document('https://converters.eionet.europa.eu/xmlfile/ias_labels.xml')/root"/>

    <xsl:variable name="measurement_units" select="$labels/measurement_units"/>

    <xsl:function name="local:get_label" as="xs:string">
        <xsl:param name="value"/>
        <xsl:param name="options"/>
        <xsl:value-of select="$options/element[value = $value]/text/text()"/>
    </xsl:function>

    <xsl:function name="local:if-empty" as="xs:string">
        <xsl:param name="value"/>
        <xsl:param name="alternate"/>

        <xsl:choose>
            <xsl:when test="string-length($value) > 0">
                <xsl:value-of select="$value"/>
            </xsl:when>
            <xsl:otherwise>-</xsl:otherwise>
        </xsl:choose>
    </xsl:function>

    <xsl:template match="/">
        <html>
            <head>
                <style type="text/css"><![CDATA[
.disabled {
    display: none;
}
#container {
    width: 75em;
    margin: auto;
    border: solid 1px #CCC;
}
div.newline-separated + div.newline-separated {
    margin-top: 1em;
}
.part-label {
    margin: 1em;
}
.form-section {
    border: solid 1px #CCC;
    border-radius: 1em;
    background-clip: border-box;
    background-color: rgb(245, 245, 245);
    margin: 1em;
}
.fs-title {
    background-clip: border-box;
    border-radius: 1em 1em 0 0;
    border-bottom: solid 1px #CCC;
}
.fs-container {
    padding: 1em;
}
.fs-container.fs-data + .fs-container.fs-data {
  /*border-top: solid 1px #CCC;*/
  padding-top: 0;
  /*margin-top: 1em;*/
}
table {
    font-size: medium;
    border-collapse: collapse;
    width: 100%;
}
table.bilateral th,
table.bilateral td{
    padding: 0.2em 1em;
    text-align: left;
    width: 15%;
}
.table-measures {
    border-collapse: initial !important;
    border-spacing: 0.5em;
}
.bordered {
    border: solid 1px #CCC;
}
.noborder {
  border: 0px !important;
  padding-top: 0px !important;
}
.padding {
    padding: 0.5em;
}
th, td {
    background-color: white;
    padding: 0.2em;
}
th {
    width: 50%;
    text-align: right;
}
.article-title {
    padding-bottom: 0em;
    font-weight: bold;
    font-size: 18px;
}
.article-title:not(.border-bottom) + .fs-data {
  padding-top: 0px;
}
.article-title .title-sub {
    font-weight: normal;
    font-size: initial;
    padding-top: 8px;
}
.title {
  font-size: 18px;
  padding: 0.5em 0;
}
.fs-data > :first-child {
  border-top: solid 1px #CCC;
  padding-top: 1em;
  width: 100%;
}
.additional-description {
  border-top: solid 1px #CCC;
  padding-top: 16px;
}
.additional-description + h4 {
  border: 0px;
}
ul {
  padding-left: 16px;
  margin: 0px;
}
h2 {
    margin: 0.5em;
}
h4 {
    padding: 1em 0em;
    margin: 0em;
    font-size: 17px;
}
span.right span {
  font-weight: normal;
}
span.right {
  float: right;
}
span.header {
  font-weight: bold;
}
span.value {
  display: block;
}
div.print-row + div.print-row {
  padding-top: 8px;
}
div.print-row + span.optional {
  display: block;
  padding-bottom: 0;
  border-bottom: 1px solid #CCC;
}
.line-separated + .line-separated {
  border-top: solid 1px #CCC;
  padding-top: 0.3em;
  margin-top: 0.3em;
}
.border-bottom {
    border-bottom: solid 1px #CCC;
    padding-bottom: 8px;
}
.padding-fix {
  padding: 16px;
}
.sub-title {
  margin: 0 12px;
}
li {
  font-size: small;
}
li span {
  font-size: initial;
}
table.pathways {
  margin: 0.5em 0;
}
table.pathways th,
table.pathways td {
  text-align: center;
  border-bottom: solid 1px #CCC;
}
table.pathways ul {
  list-style-type: none;
  font-size: initial;
}
table.pathways ul li {
  font-size: initial;
}
]]>
                </style>
            </head>
            <body>
                <div id="container">
                    <xsl:call-template name="tab_0"/>
                    <xsl:call-template name="tab_1"/>
                    <xsl:call-template name="tab_2"/>
                    <xsl:call-template name="tab_3"/>
                    <xsl:call-template name="tab_4"/>
                </div>
            </body>
        </html>
    </xsl:template>

    <xsl:template name="tab_0">
        <xsl:variable name="root" select="./*[1]"/>
        <xsl:variable name="reporting_party" select="$root//*:reporting"/>

        <h2>Information on the reporting party</h2>
        <div class="tab_0 form-section">
            <div class="fs-container fs-title">
                <xsl:for-each select="$labels/tab_0/description">
                    <div class="newline-separated">
                        <xsl:value-of select="."/>
                    </div>
                </xsl:for-each>
            </div>
            <div class="fs-container fs-data">
                <table class="bilateral bordered">
                    <xsl:for-each select="$labels/tab_0/form_fields/*">
                        <tr>
                            <th>
                                <xsl:value-of select="./label"/>
                            </th>
                            <td>
                                <xsl:call-template name="simple-print">
                                    <xsl:with-param name="label" select="''"/>
                                    <xsl:with-param name="value" select="$reporting_party/*:Row/*[local-name() = current()/name]"/>
                                </xsl:call-template>
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="tab_1">
        <xsl:variable name="tab1" select="$labels/tab_1"/>
        <xsl:variable name="fields" select="$tab1/fields"/>
        <xsl:variable name="sectionASpecies" select="//*:sectionASpecies"/>
        <xsl:variable name="spreadPatterns" select="//*:spreadPatterns"/>
        <xsl:variable name="table" select="$tab1"/>

        <h2>
            Information to be submitted for each of the invasive alien species of Union concern and for each invasive alien species of regional concern subject to measures as provided for in Article 11(2) of Regulation (EU) No 1143/2014
        </h2>
        <!--<div class="sub-title">Sub title</div>-->

        <div class="tab_1 form-section">
            <table class="table-measures">
                <div class="fs-container fs-title">
                    <xsl:value-of select="$tab1/description"/>
                </div>
                <xsl:for-each select="$tab1/species/element">
                    <xsl:variable name="species" select="current()"/>
                    <xsl:variable name="species_title" select="$species/speciesNameLegi/text()"/>
                    <xsl:variable name="optional" select="$species/optional"/>
                    <xsl:variable name="EASINCode" select="$species/speciesCode"/>
                    <xsl:variable name="report-node" select="$sectionASpecies/*:Row[*:EASINCode = $EASINCode]"/>
                    <xsl:variable name="row_id" select="$report-node/*:row_id"/>
                    <xsl:variable name="present_in_MS" select="$report-node/*:present_in_MS"/>

                    <tr>
                    <td class="bordered">
                        <!-- debug -->
                        <!--<div>EASINCode: <xsl:value-of select="$EASINCode"/></div>-->
                        <!--<div>row_id: <xsl:value-of select="$row_id"/></div>-->
                        <!--<div>options: <xsl:value-of select="$options-label"/></div>-->

                        <div class="fs-container article-title">
                            <xsl:if test="$optional = 'true'">
                                <span class="optional">Optional: </span>
                            </xsl:if>
                            <xsl:value-of select="$species_title"/>
                            <span class="right">
                                <span><xsl:value-of select="$fields/species_code/label"/></span>:
                                <xsl:value-of select="$species/speciesCode"/>
                            </span>
                        </div>
                        <!-- debug -->
                        <!--<xsl:value-of select="$collection_id"/> - <xsl:value-of select="$parent_collection_id"/>-->

                        <div class="fs-container fs-data">
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="$fields/common_name/label"/>
                                <xsl:with-param name="value" select="$species/speciesCNameEN"/>
                            </xsl:call-template>

                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="$fields/common_name/labelLanguage"/>
                                <xsl:with-param name="value" select="$report-node/*:common_name_national"/>
                            </xsl:call-template>

                            <xsl:call-template name="choose-print">
                                <xsl:with-param name="options" select="$fields/mandatory_item/options"/>
                                <xsl:with-param name="label" select="$fields/mandatory_item/label"/>
                                <xsl:with-param name="value" select="$present_in_MS"/>
                            </xsl:call-template>
                        </div>
                        <xsl:if test="$present_in_MS = 'true'">
                            <div class="fs-container fs-data">
                                <xsl:call-template name="choose-print">
                                    <xsl:with-param name="options" select="$fields/depending_on_mandatory/reproduction_patterns/element/options"/>
                                    <xsl:with-param name="label" select="$fields/depending_on_mandatory/reproduction_patterns/element/label"/>
                                    <xsl:with-param name="value" select="$report-node/*:reproduction_pattern"/>
                                </xsl:call-template>
                                <xsl:call-template name="multichoose-print">
                                    <xsl:with-param name="options" select="$fields/depending_on_mandatory/spread_patterns/element/options"/>
                                    <xsl:with-param name="label" select="$fields/depending_on_mandatory/spread_patterns/element/label"/>
                                    <xsl:with-param name="values" select="$spreadPatterns/*:Row[*:EASINCode = $EASINCode and *:section='A']/*:spread_pattern"/>
                                </xsl:call-template>
                                <xsl:call-template name="simple-print">
                                    <xsl:with-param name="label" select="$fields/additional_info/label"/>
                                    <xsl:with-param name="value" select="$report-node/*:additional_information"/>
                                </xsl:call-template>
                            </div>
                        </xsl:if>

                        <xsl:call-template name="tab_1_table1">
                            <xsl:with-param name="report-node" select="$report-node"/>
                        </xsl:call-template>

                        <xsl:call-template name="tab_1_table2">
                            <xsl:with-param name="report-node" select="$report-node"/>
                            <xsl:with-param name="table" select="$labels/tab_1/tables/table_2"/>
                        </xsl:call-template>

                        <xsl:call-template name="tab_1_table3">
                            <xsl:with-param name="report-node" select="$report-node"/>
                            <xsl:with-param name="table" select="$labels/tab_1/tables/table_3"/>
                        </xsl:call-template>

                        <xsl:call-template name="tab_1_table4">
                            <xsl:with-param name="report-node" select="$report-node"/>
                            <xsl:with-param name="table" select="$labels/tab_1/tables/table_4"/>
                        </xsl:call-template>

                        <!-- NOT USED -->
                        <xsl:for-each select="$species/items/element">
                            <xsl:variable name="type" select="current()/type"/>
                            <xsl:variable name="node_name" select="current()/name"/>
                            <xsl:choose>
                                <xsl:when test="$type = ('checkbox')">
                                    <xsl:call-template name="checkbox-print">
                                        <xsl:with-param name="options" select="()"/>
                                        <xsl:with-param name="label" select="current()/label"/>
                                        <xsl:with-param name="report-data-node" select="''"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="$type = ('changes', 'status')">
                                    <xsl:call-template name="choose-print">
                                        <xsl:with-param name="options" select="()"/>
                                        <xsl:with-param name="label" select="current()/label"/>
                                        <xsl:with-param name="value" select="''"/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:when test="$type = ('number')">
                                    <xsl:call-template name="simple-print">
                                        <xsl:with-param name="label" select="current()/label"/>
                                        <xsl:with-param name="value" select="''"/>
                                    </xsl:call-template>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:for-each>
                    </td>
                    </tr>
                </xsl:for-each>
            </table>
        </div>
    </xsl:template>

    <xsl:template name="tab_1_table1">
        <xsl:param name="report-node"/>

        <xsl:variable name="parent_row_id" select="$report-node/*:row_id"/>
        <xsl:variable name="table1" select="$labels/tab_1/tables/table_1"/>
        <xsl:variable name="permits_issued" select="$report-node/*:permits_issued"/>
        <xsl:variable name="permitedSpecimens" select="$report-node/ancestor::IAS/*:permitedSpecimens"/>
        <xsl:variable name="inspectionsPermits" select="$report-node/ancestor::IAS/*:inspectionsPermits"/>

        <div class="tab_1 table_1 fs-container fs-data">
            <div class="article-title title">
                <xsl:value-of select="$table1/label"/>
            </div>
            <xsl:call-template name="choose-print">
                <xsl:with-param name="options" select="$table1/question/options"/>
                <xsl:with-param name="label" select="$table1/question/label"/>
                <xsl:with-param name="value" select="$permits_issued"/>
            </xsl:call-template>

            <xsl:if test="$permits_issued = 'true'">
                <xsl:for-each select="$table1/table_sections/element">
                    <xsl:variable name="section" select="current()"/>
                    <xsl:variable name="permits-node-name" select="current()/permits_node"/>
                    <xsl:variable name="permits-nodes" select="$report-node/ancestor::IAS/*[local-name() = $permits-node-name]/*:Row[*:parent_row_id = $parent_row_id]"/>

                    <xsl:if test="string-length($section/label) > 0">
                        <div class="title">
                            <xsl:value-of select="$section/label"/>
                        </div>
                    </xsl:if>
                    <div class="fs-container bordered">
                        <xsl:for-each select="$permits-nodes">
                            <div class="line-separated">
                                <xsl:variable name="permits-node" select="current()"/>
                                <xsl:variable name="row_id" select="$permits-node/*:row_id"/>
                                <!-- debug -->
                                <!--<div>parent_row_id: <xsl:value-of select="$parent_row_id"/></div>-->
                                <!--<div>row_id: <xsl:value-of select="$row_id"/></div>-->

                                <xsl:for-each select="$section/table_fields/optionsFields/element[1]/fields/element">
                                    <xsl:variable name="field" select="current()"/>
                                    <xsl:variable name="name" select="$field/name"/>
                                    <xsl:variable name="permit_type" select="$field/permit_type"/>
                                    <xsl:variable name="inspection_status" select="$field/inspection_status"/>

                                    <!-- debug -->
                                    <!--<xsl:value-of select="$permit_type"/>-->

                                    <xsl:choose>
                                        <xsl:when test="$name = 'year'">
                                            <xsl:call-template name="simple-print">
                                                <xsl:with-param name="label" select="$field/label"/>
                                                <xsl:with-param name="value" select="$permits-node/*[local-name() = $name]"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:when test="$name = ('number_issued', 'number_valid', 'number_establishment', 'number_inspected')">
                                            <xsl:call-template name="simple-print">
                                                <xsl:with-param name="label" select="$field/label"/>
                                                <xsl:with-param name="value" select="$permits-node/*[local-name() = $name]"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:when test="$name = ('permit_purpose')">
                                            <xsl:call-template name="choose-print">
                                                <xsl:with-param name="options" select="$field/options"/>
                                                <xsl:with-param name="label" select="$field/label"/>
                                                <xsl:with-param name="value" select="$permits-node/*[local-name() = $name]"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:when test="string-length($permit_type) > 0">
                                            <xsl:call-template name="list-print">
                                                <xsl:with-param name="label" select="$field/label"/>
                                                <xsl:with-param name="values" select="$permitedSpecimens/*:Row[*:parent_row_id = $row_id and string-length(*:value) > 0
                                                    and *:permit_type = $permit_type]/concat(*:value, ' ', local:get_label(*:unit, $measurement_units/descendant-or-self::options))"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:when test="string-length($inspection_status) > 0">
                                            <xsl:call-template name="list-print">
                                                <xsl:with-param name="label" select="$field/label"/>
                                                <xsl:with-param name="values" select="$inspectionsPermits/*:Row[*:parent_row_id = $row_id and string-length(*:value) > 0
                                                    and *:inspection_status = $inspection_status]/concat(*:value, ' ', local:get_label(*:unit, $measurement_units/descendant-or-self::options))"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="simple-print">
                                                <xsl:with-param name="label" select="$field/label"/>
                                                <xsl:with-param name="value" select="'#unknown'"/>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:for-each>
                            </div>
                        </xsl:for-each>
                        <xsl:if test="exists($section/noinspections)">
                            <div class="line-separated">
                                <xsl:call-template name="simple-print">
                                    <xsl:with-param name="label" select="$section/noinspections/options/element/text"/>
                                    <xsl:with-param name="value">
                                        <xsl:choose>
                                            <xsl:when test="$report-node/*:no_inspections_reported = 'true'">Yes</xsl:when>
                                            <!--<xsl:when test="$report-node/*:no_inspections_reported = 'false'">No</xsl:when>-->
                                            <xsl:otherwise>-</xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </div>
                        </xsl:if>
                        <div class="line-separated">
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="$section/additional_info/label"/>
                                <xsl:with-param name="value" select="$report-node/*[local-name() = $section/additional_info/name]"/>
                            </xsl:call-template>
                        </div>
                    </div>
                </xsl:for-each>
            </xsl:if>
        </div>
    </xsl:template>

    <xsl:template name="tab_1_table2">
        <xsl:param name="report-node"/>
        <xsl:param name="table"/>

        <xsl:variable name="species_id" select="$report-node/*:row_id"/>
        <xsl:variable name="eradication_measures" select="$report-node/*:eradication_measures"/>
        <xsl:variable name="sectionAMeasures" select="$report-node/ancestor::IAS/*:sectionAMeasures
            /*:Row[*:measure_type/text() = 'eradication' and *:parent_row_id = $species_id]"/>
        <xsl:variable name="section" select="$table/table_sections/element"/>
        <xsl:variable name="fields" select="$section/table_fields/fields"/>
        <xsl:variable name="observedNegativeImpacts" select="$report-node/ancestor::IAS/*:observedNegativeImpacts"/>

        <div class="tab_1 table_2 fs-container fs-data">
            <div class="article-title title noborder">
                <xsl:value-of select="$table/label"/>
            </div>
            <xsl:call-template name="choose-print">
                <xsl:with-param name="options" select="$table/question/options"/>
                <xsl:with-param name="label" select="$table/question/label"/>
                <xsl:with-param name="value" select="$eradication_measures"/>
            </xsl:call-template>
            <xsl:if test="$eradication_measures = 'true'">
                <div class="fs-container bordered">
                    <!-- Debug -->
                    <!--<div>species_id: <xsl:value-of select="$species_id"/></div>-->

                    <xsl:for-each select="$sectionAMeasures">
                        <xsl:variable name="sectionA-node" select="current()"/>
                        <xsl:variable name="measure_id" select="$sectionA-node/*:row_id"/>
                        <div class="line-separated">
                            <!-- debug -->
                            <!--<div>measure_id: <xsl:value-of select="$measure_id"/></div>-->

                            <!-- Population -->
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="'Population'"/>
                                <xsl:with-param name="value" select="$sectionA-node/*:population_name"/>
                            </xsl:call-template>

                            <!-- Measures-->
                            <span class="optional title">Measure(s)</span>
                            <xsl:for-each select="$fields/element[1]/fields/element">
                                <xsl:variable name="field" select="current()"/>
                                <xsl:variable name="type" select="$field/type"/>
                                <xsl:variable name="name" select="$field/name"/>
                                <xsl:variable name="data-rows" select="$report-node/ancestor::IAS/*[local-name() = $name]
                                    /*:Row[*:parent_row_id = $measure_id]"/>

                                <!-- TODO not finished -->
                                <xsl:choose>
                                    <xsl:when test="$type = ('date')">
                                        <xsl:call-template name="simple-print">
                                            <xsl:with-param name="label" select="$field/label"/>
                                            <xsl:with-param name="value" select="$sectionA-node/*[local-name() = $name]"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:when test="$type = ('multiselect')">
                                        <xsl:call-template name="multichoose-print">
                                            <xsl:with-param name="options" select="$field/options"/>
                                            <xsl:with-param name="label" select="$field/label"/>
                                            <xsl:with-param name="values" select="$data-rows/*:methods_used"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:when test="$type = ('listprint')">
                                        <xsl:call-template name="list-print">
                                            <xsl:with-param name="label" select="$field/label"/>
                                            <xsl:with-param name="values" select="$data-rows/*:name"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:call-template name="simple-print">
                                            <xsl:with-param name="label" select="$field/label"/>
                                            <xsl:with-param name="value" select="'#unknown'"/>
                                        </xsl:call-template>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:for-each>

                            <!-- Effectiveness of measure -->
                            <span class="optional title">
                                <xsl:value-of select="$fields/element[2]/label"/>
                            </span>
                            <xsl:call-template name="choose-print">
                                <xsl:with-param name="options" select="$fields/element[2]/fields/element/options"/>
                                <xsl:with-param name="label" select="''"/>
                                <xsl:with-param name="value" select="$sectionA-node/*:measure_effectiveness"/>
                            </xsl:call-template>

                            <!-- TODO do it later -->
                            <!-- Observed negative impacts of the measure on non-targeted species -->
                            <xsl:call-template name="list-print">
                                <xsl:with-param name="label" select="$fields/element[3]/main_header"/>
                                <xsl:with-param name="values" select="$observedNegativeImpacts/*:Row[*:parent_row_id = $measure_id]
                                /concat('Impacted non-targeted species: ', local:if-empty(*:non_targeted_species, '-'), ' / Impact per species: ', local:if-empty(*:species, '-'))"/>
                            </xsl:call-template>

                            <!-- No inspections reported -->
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="$fields/element[4]/options/element/text"/>
                                <xsl:with-param name="value">
                                    <xsl:choose>
                                        <xsl:when test="$sectionA-node/*:no_negative_impact = 'true'">Yes</xsl:when>
                                        <!--<xsl:when test="$report-node/*:no_inspections_reported = 'false'">No</xsl:when>-->
                                        <xsl:otherwise>-</xsl:otherwise>
                                    </xsl:choose>
                                </xsl:with-param>
                            </xsl:call-template>

                            <!-- additional info -->
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="$section/additional_info/label"/>
                                <xsl:with-param name="value" select="$sectionA-node/*:additional_information"/>
                            </xsl:call-template>
                        </div>
                    </xsl:for-each>
                </div>
            </xsl:if>
        </div>
    </xsl:template>

    <xsl:template name="tab_1_table3">
        <xsl:param name="report-node"/>
        <xsl:param name="table"/>

        <xsl:variable name="species_id" select="$report-node/*:row_id"/>
        <xsl:variable name="subject_management_measures" select="$report-node/*:subject_management_measures"/>
        <xsl:variable name="sectionAMeasures" select="$report-node/ancestor::IAS/*:sectionAMeasures
            /*:Row[*:measure_type/text() = 'management' and *:parent_row_id = $species_id]"/>
        <xsl:variable name="section" select="$table/table_sections/element"/>
        <xsl:variable name="fields" select="$section/table_fields/fields"/>
        <xsl:variable name="observedNegativeImpacts" select="$report-node/ancestor::IAS/*:observedNegativeImpacts"/>

        <div class="tab_1 table_3 fs-container fs-data">
            <div class="article-title title noborder">
                <xsl:value-of select="$table/label"/>
            </div>
            <xsl:call-template name="choose-print">
                <xsl:with-param name="options" select="$table/question/options"/>
                <xsl:with-param name="label" select="$table/question/label"/>
                <xsl:with-param name="value" select="$subject_management_measures"/>
            </xsl:call-template>
            <xsl:if test="$subject_management_measures = 'true'">
                <div class="fs-container bordered">
                    <!-- Debug -->
                    <!--<div>species_id: <xsl:value-of select="$species_id"/></div>-->

                    <xsl:for-each select="$sectionAMeasures">
                        <xsl:variable name="sectionA-node" select="current()"/>
                        <xsl:variable name="measure_id" select="$sectionA-node/*:row_id"/>
                        <div class="line-separated">
                            <!-- debug -->
                            <!--<div>measure_id: <xsl:value-of select="$measure_id"/></div>-->

                            <!-- Population -->
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="'Population'"/>
                                <xsl:with-param name="value" select="$sectionA-node/*:population_name"/>
                            </xsl:call-template>

                            <!-- Measures-->
                            <span class="optional title">Measure(s)</span>
                            <xsl:for-each select="$fields/element[1]/fields/element">
                                <xsl:variable name="field" select="current()"/>
                                <xsl:variable name="type" select="$field/type"/>
                                <xsl:variable name="name" select="$field/name"/>
                                <xsl:variable name="data-rows" select="$report-node/ancestor::IAS/*[local-name() = $name]
                                    /*:Row[*:parent_row_id = $measure_id]"/>

                                <!-- TODO not finished -->
                                <xsl:choose>
                                    <xsl:when test="$type = ('date')">
                                        <xsl:call-template name="simple-print">
                                            <xsl:with-param name="label" select="$field/label"/>
                                            <xsl:with-param name="value" select="$sectionA-node/*[local-name() = $name]"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:when test="$type = ('select')">
                                        <xsl:call-template name="choose-print">
                                            <xsl:with-param name="options" select="$field/options"/>
                                            <xsl:with-param name="label" select="$field/label"/>
                                            <xsl:with-param name="value" select="$sectionA-node/*:measure_objective"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:when test="$type = ('multiselect')">
                                        <xsl:call-template name="multichoose-print">
                                            <xsl:with-param name="options" select="$field/options"/>
                                            <xsl:with-param name="label" select="$field/label"/>
                                            <xsl:with-param name="values" select="$data-rows/*:methods_used"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:when test="$type = ('listprint')">
                                        <xsl:call-template name="list-print">
                                            <xsl:with-param name="label" select="$field/label"/>
                                            <xsl:with-param name="values" select="$data-rows/*:name"/>
                                        </xsl:call-template>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:call-template name="simple-print">
                                            <xsl:with-param name="label" select="$field/label"/>
                                            <xsl:with-param name="value" select="'#unknown'"/>
                                        </xsl:call-template>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:for-each>

                            <!-- Effectiveness of measure -->
                            <span class="optional title">
                                <xsl:value-of select="$fields/element[2]/label"/>
                            </span>
                            <xsl:call-template name="choose-print">
                                <xsl:with-param name="options" select="$fields/element[2]/fields/element/options"/>
                                <xsl:with-param name="label" select="''"/>
                                <xsl:with-param name="value" select="$sectionA-node/*:measure_effectiveness"/>
                            </xsl:call-template>

                            <!-- TODO do it later -->
                            <!-- Observed negative impacts of the measure on non-targeted species -->
                            <xsl:call-template name="list-print">
                                <xsl:with-param name="label" select="$fields/element[3]/main_header"/>
                                <xsl:with-param name="values" select="$observedNegativeImpacts/*:Row[*:parent_row_id = $measure_id]
                                /concat('Impacted non-targeted species: ', local:if-empty(*:non_targeted_species, '-'), ' / Impact per species: ', local:if-empty(*:species, '-'))"/>
                            </xsl:call-template>

                            <!-- No inspections reported -->
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="$fields/element[4]/options/element/text"/>
                                <xsl:with-param name="value">
                                    <xsl:choose>
                                        <xsl:when test="$sectionA-node/*:no_negative_impact = 'true'">Yes</xsl:when>
                                        <!--<xsl:when test="$report-node/*:no_inspections_reported = 'false'">No</xsl:when>-->
                                        <xsl:otherwise>-</xsl:otherwise>
                                    </xsl:choose>
                                </xsl:with-param>
                            </xsl:call-template>

                            <!-- additional info -->
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="$section/additional_info/label"/>
                                <xsl:with-param name="value" select="$sectionA-node/*:additional_information"/>
                            </xsl:call-template>
                        </div>
                    </xsl:for-each>
                </div>
            </xsl:if>
        </div>
    </xsl:template>

    <xsl:template name="tab_1_table4">
        <xsl:param name="report-node"/>
        <xsl:param name="table"/>

        <xsl:variable name="species_row_id" select="$report-node/*:row_id"/>
        <xsl:variable name="infoImpactSpecies" select="$report-node/ancestor::IAS/*:infoImpactSpecies/*:Row[*:parent_row_id = $species_row_id]"/>

        <div class="tab_1 table_4 fs-container fs-data">
            <div class="article-title title noborder">
                <xsl:value-of select="$table/label"/>
            </div>
            <div class="title">
                <xsl:value-of select="$table/info"/>
            </div>
            <xsl:choose>
                <xsl:when test="count($infoImpactSpecies) > 0">
                    <div class="fs-container bordered">
                        <xsl:for-each select="$infoImpactSpecies">
                            <xsl:variable name="impact-node" select="current()"/>
                            <xsl:variable name="impact_row_id" select="$impact-node/*:row_id"/>

                            <div class="line-separated">
                                <xsl:for-each select="$table/table_sections/element/table_fields/element/fields/element">
                                    <xsl:variable name="field" select="current()"/>
                                    <xsl:variable name="type" select="$field/type"/>
                                    <xsl:variable name="name" select="$field/name"/>

                                    <xsl:choose>
                                        <xsl:when test="$type = ('textarea')">
                                            <xsl:call-template name="simple-print">
                                                <xsl:with-param name="label" select="$field/label"/>
                                                <xsl:with-param name="value" select="$impact-node/*:impact"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:when test="$type = ('multiselect')">
                                            <xsl:call-template name="list-print">
                                                <xsl:with-param name="label" select="$field/label"/>
                                                <xsl:with-param name="values" select="$report-node/ancestor::IAS/*[local-name() = $name]/*:Row[*:parent_row_id = $impact_row_id]/*:name"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:when test="$type = ('custom')">
                                            <xsl:call-template name="list-print">
                                                <xsl:with-param name="label" select="$field/label"/>
                                                <xsl:with-param name="values" select="$report-node/ancestor::IAS/*[local-name() = $name]
                                                        /*:Row[*:parent_row_id = $impact_row_id]/concat(*:group, ' - ', *:class)"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="simple-print">
                                                <xsl:with-param name="label" select="$field/label"/>
                                                <xsl:with-param name="value" select="'#unknown'"/>
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:for-each>
                            </div>
                        </xsl:for-each>
                    </div>
                </xsl:when>
                <xsl:otherwise>-</xsl:otherwise>
            </xsl:choose>
        </div>

    </xsl:template>

    <xsl:template name="tab_2">
        <xsl:variable name="tab2" select="$labels/tab_2"/>
        <xsl:variable name="sectionBSpecies" select="//*:sectionBSpecies"/>
        <xsl:variable name="sectionBMeasures" select="//*:sectionBMeasures"/>
        <xsl:variable name="spreadPatterns" select="//*:spreadPatterns"/>
        <xsl:variable name="tab2_reported">
            <xsl:choose>
                <xsl:when test="count($sectionBSpecies//*:Row) > 0">true</xsl:when>
                <xsl:otherwise>false</xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="fields" select="$tab2/fields"/>

        <h2>
            Information to be submitted for each of the invasive alien species of Member State concern
        </h2>
        <div class="tab_2 form-section">
            <table class="table-measures">
                <div class="fs-container">
                    <xsl:call-template name="choose-print">
                        <xsl:with-param name="options" select="$tab2/question/options"/>
                        <xsl:with-param name="label" select="$tab2/question/label"/>
                        <xsl:with-param name="value" select="$tab2_reported"/>
                    </xsl:call-template>
                </div>
                <xsl:for-each select="$sectionBSpecies/*:Row">
                    <xsl:variable name="species-node" select="current()"/>
                    <xsl:variable name="EASINCode" select="$species-node/*:EASINCode"/>
                    <xsl:variable name="species_id" select="$species-node/*:row_id"/>

                    <tr>
                    <td class="bordered">
                        <div class="fs-container article-title">
                            Species scientific name: <xsl:value-of select="$species-node/*:scientific_name"/>
                        </div>
                        <div class="fs-container fs-data">
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="$fields/common_name/label"/>
                                <xsl:with-param name="value" select="$species-node/*:common_name_national"/>
                            </xsl:call-template>
                            <xsl:call-template name="choose-print">
                                <xsl:with-param name="options" select="$fields/present_in_MS/options"/>
                                <xsl:with-param name="label" select="$fields/present_in_MS/label"/>
                                <xsl:with-param name="value" select="$species-node/*:present_in_MS"/>
                            </xsl:call-template>
                            <xsl:call-template name="choose-print">
                                <xsl:with-param name="options" select="$fields/reproduction/options"/>
                                <xsl:with-param name="label" select="$fields/reproduction/label"/>
                                <xsl:with-param name="value" select="$species-node/*:reproduction_pattern"/>
                            </xsl:call-template>
                            <xsl:call-template name="multichoose-print">
                                <xsl:with-param name="options" select="$fields/spread_patterns/options"/>
                                <xsl:with-param name="label" select="$fields/spread_patterns/label"/>
                                <xsl:with-param name="values" select="$spreadPatterns/*:Row[*:EASINCode = $EASINCode and *:section = 'B']/*:spread_pattern"/>
                            </xsl:call-template>
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="$fields/additional_information/label"/>
                                <xsl:with-param name="value" select="$species-node/*:additional_information"/>
                            </xsl:call-template>
                            <xsl:call-template name="multichoose-print">
                                <xsl:with-param name="options" select="$fields/measures/options"/>
                                <xsl:with-param name="label" select="$fields/measures/label"/>
                                <xsl:with-param name="values" select="$sectionBMeasures/*:Row[*:parent_row_id = $species_id]/*:measure"/>
                            </xsl:call-template>
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="$fields/additional_info_measures/label"/>
                                <xsl:with-param name="value" select="$species-node/*:additional_information_measures"/>
                            </xsl:call-template>
                        </div>
                    </td>
                    </tr>
                </xsl:for-each>
            </table>
        </div>
    </xsl:template>

    <xsl:template name="tab_3">
        <xsl:variable name="tab3" select="$labels/tab_3"/>
        <xsl:variable name="sectionC" select="//*:sectionC/*:Row"/>
        <xsl:variable name="priorityPathway" select="//*:priorityPathway"/>
        <xsl:variable name="row_ids" select="distinct-values($priorityPathway//*:row_id/text())"/>
        <xsl:variable name="fields" select="$tab3/fields"/>

        <h2>
            Horizontal information
        </h2>
        <div class="tab_3 form-section">
            <table class="table-measures">
                <tr>
                <td class="bordered">
                    <div class="fs-container">
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/weblink_permits/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:weblink_permits"/>
                        </xsl:call-template>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/action_plans/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:action_plans"/>
                        </xsl:call-template>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/file_action_plans/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:file_action_plans"/>
                        </xsl:call-template>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/surveillance_system/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:surveillance_system"/>
                        </xsl:call-template>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/file_surveillance_system/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:file_surveillance_system"/>
                        </xsl:call-template>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/official_control_system/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:official_control_system"/>
                        </xsl:call-template>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/file_official_control_system/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:file_official_control_system"/>
                        </xsl:call-template>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/measures_inform_public/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:measures_inform_public"/>
                        </xsl:call-template>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/file_measures_inform_public/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:file_measures_inform_public"/>
                        </xsl:call-template>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/cost_of_action/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:cost_of_action"/>
                        </xsl:call-template>
                        <xsl:if test="count($priorityPathway) > 0">
                            <table class="pathways">
                                <tr>
                                    <th>Priority pathways addressed</th>
                                    <th>Species covered</th>
                                </tr>
                                <xsl:for-each select="$row_ids">
                                    <xsl:variable name="row_id" select="current()"/>
                                    <tr>
                                        <td>
                                            <xsl:value-of select="local:get_label($priorityPathway/*:Row[*:row_id = $row_id][1]/*:pathway_code,
                                                                                    $labels/priority_pathways/options)"/>
                                        </td>
                                        <td>
                                            <ul>
                                                <xsl:for-each select="$priorityPathway/*:Row[*:row_id = $row_id]/*:EASINCode">
                                                    <li><xsl:value-of select="$labels/tab_1/species/element[speciesCode = current()]/speciesNameLegi"/></li>
                                                </xsl:for-each>
                                            </ul>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                            </table>
                        </xsl:if>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/file_cost_of_action/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:file_cost_of_action"/>
                        </xsl:call-template>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/additional_information/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:additional_information"/>
                        </xsl:call-template>
                        <xsl:call-template name="simple-print">
                            <xsl:with-param name="label" select="$fields/file_additional_information/label"/>
                            <xsl:with-param name="value" select="$sectionC/*:file_additional_information"/>
                        </xsl:call-template>
                    </div>
                </td>
                </tr>
            </table>
        </div>
    </xsl:template>

    <xsl:template name="tab_4">
        <xsl:variable name="tab4" select="$labels/tab_4"/>
        <xsl:variable name="distributionMap" select="//*:distributionMap/*:Row"/>
        <xsl:variable name="fields" select="$tab4/fields/*"/>

        <h2>
            Distribution maps for the Section A - IAS of Union concern and Section B – IAS of Member States concern
        </h2>
        <div class="tab_4 form-section">
            <table class="table-measures">
                <tr>
                <td class="bordered">
                    <div class="fs-container">
                        <xsl:for-each select="$fields">
                            <xsl:call-template name="simple-print">
                                <xsl:with-param name="label" select="current()/label"/>
                                <xsl:with-param name="value" select="$distributionMap/*[local-name() = current()/name]"/>
                            </xsl:call-template>
                        </xsl:for-each>
                    </div>
                </td>
                </tr>
            </table>
        </div>
    </xsl:template>

    <xsl:template name="choose-print">
        <xsl:param name="options"/>
        <xsl:param name="label"/>
        <xsl:param name="value"/>

        <xsl:variable name="new_value" as="xs:string*">
            <xsl:choose>
                <xsl:when test="exists($options//*)">
                    <xsl:for-each select="$value[text()]">
                        <xsl:sequence select="local:get_label(current()/text(), $options/descendant-or-self::options)"/>
                    </xsl:for-each>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:sequence select="$value"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:call-template name="list-print">
            <xsl:with-param name="label" select="$label"/>
            <xsl:with-param name="values" select="$new_value"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="multichoose-print">
        <xsl:param name="options"/>
        <xsl:param name="label"/>
        <xsl:param name="values"/>

        <xsl:variable name="new_value" select="$values/local:get_label(text(), $options/descendant-or-self::options)"/>
        <!--<xsl:variable name="new_value" select="$values"/>-->

        <xsl:call-template name="list-print">
            <xsl:with-param name="label" select="$label"/>
            <xsl:with-param name="values" select="$new_value"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="checkbox-print">
        <xsl:param name="options"/>
        <xsl:param name="label"/>
        <xsl:param name="report-data-node"/>

        <xsl:variable name="new_values" select="$report-data-node/value[text()]/local:get_label(text(), $options//options)"/>

        <xsl:call-template name="list-print">
            <xsl:with-param name="label" select="$label"/>
            <xsl:with-param name="values" select="$new_values"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="simple-print">
        <xsl:param name="label"/>
        <xsl:param name="value"/>
        <div class="print-row">
            <span class="header">
                <xsl:value-of select="$label"/>
            </span>
            <span class="value">
                <xsl:choose>
                    <xsl:when test="string-length($value) > 0">
                        <xsl:value-of select="$value"/>
                    </xsl:when>
                    <xsl:otherwise>-</xsl:otherwise>
                </xsl:choose>
            </span>
        </div>
    </xsl:template>

    <xsl:template name="list-print">
        <xsl:param name="label"/>
        <xsl:param name="values"/>
        <div class="print-row">
            <span class="header">
                <xsl:value-of select="$label"/>
            </span>
            <span class="value">
                <xsl:choose>
                    <xsl:when test="count($values) > 0">
                        <ul>
                            <xsl:for-each select="$values">
                                <li>
                                    <span><xsl:value-of select="current()"/></span>
                                </li>
                            </xsl:for-each>
                        </ul>
                    </xsl:when>
                    <xsl:otherwise>-</xsl:otherwise>
                </xsl:choose>
            </span>
        </div>
    </xsl:template>

</xsl:stylesheet>