View stylesheet

XML schema http://dd.eionet.europa.eu/schemas/habitatsdirective/art17_species_checklist.xsd
Output type HTML
Description HTML Factsheet
XSL file species-checklist-2018.xsl (Last modified: 07 Feb 2019 14:01 )
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:lookup="http://biodiversity.eionet.europa.eu/art17dataflow" version="1.0" exclude-result-prefixes="xml lookup">
    <xsl:output method="xml" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" omit-xml-declaration="yes" />
    <xsl:param name="envelopeurl" />
    <xsl:param name="envelopepath" />
    <xsl:param name="filename" />
    <xsl:preserve-space elements="published reasons-specify" />
    <xsl:template match="member_state_checklist">
        <html>
            <xsl:attribute name="xml:lang">
                <xsl:value-of select="@xml:lang" />
            </xsl:attribute>
            <head>
                <meta charset="UTF-8"/>
                <title>Factsheet</title>
                <style type="text/css">
                    <![CDATA[
                        img {
                            border: 2px solid #ccc;
                            margin: 10px;
                        }
                        h2 {
                            font-family: arial, verdana, sans-serif;
                        }
                        h1 {
                            font-size: 160%;
                            padding-bottom: 0.5em;
                            border-bottom: 1px solid #999999;
                        }
                        body {
                            font-size: 80%;
                            font-family: verdana, helvetica, arial, sans-serif;
                            color: #333;
                        }
                        caption {
                            display: none;
                            font-family: vardana, verdana, helvetica, arial, sans-serif;
                            text-align: left;
                            font-size: 150%;
                        }
                        th {
                            background-color:#f6f6f6;
                            text-align:left;
                            vertical-align: top;
                            font-weight: normal;
                            color: black;
                        }
                        table {
                            font-size: 100%;
                            border: 1px solid #bbb;
                            width: 60%;
                            margin: 0 0 2em 0;
                            border-collapse: collapse;
                        }
                        table table {
                            border: 0px solid #bbb;
                            margin: 0;
                        }
                        th, td {
                            font-size: 100%;
                            border: 1px solid #bbb;
                        }
                        .has_table {
                            border: 0px solid #bbb;
                            padding: 0;
                        }
                        th.header_3 {
                            padding: 0.4em 0;
                            font-size: 120%;
                            font-weight: bold;
                        }
                        th.tlabel {
                            width: 300px;
                        }
                        .header_info {
                            margin: 20px 0px;
                            padding: 5px;
                            font-size: 120%;
                            border: 1px dashed #999999;
                            background-color: #f0f0f0;
                        }
                        .header_info div {
                            margin: 5px;
                        }
                        p.report_end {
                            border-bottom: dashed;
                            border-width: 2px;
                            border-color: #000000;
                        }
                    ]]>
                </style>
            </head>
            <body>
                <h1>Check lists for Habitats Directive Article 17 reporting</h1>
                <h2>Species and Regional Levels for the Member State <xsl:value-of select="country" /></h2>
                <xsl:apply-templates select="species_list" />
            </body>
        </html>
    </xsl:template>
    <xsl:template match="species_list">
        The checklist contains <b><xsl:value-of select="count(species)" /></b> species and <b><xsl:value-of select="count(species/regional/region)" /></b> regional levels<br /><br />
        Predefined (not changed) items:<b><xsl:value-of select="count(species/regional/region[predefined='true'])" /></b><br />
        Changed by the member state:<b><xsl:value-of select="count(species/regional/region[predefined='false' and ms_added='false'])" /></b><br />
        New items added by the member state:<b><xsl:value-of select="count(species/regional/region[ms_added='true'])" /></b><br />
        <xsl:apply-templates />
    </xsl:template>
    <xsl:template match="species">
        <h3>Species Code: <xsl:value-of select="code" /></h3>
        <h4><xsl:value-of select="name" /></h4>
        <xsl:apply-templates select="regional" />
        <p class="report_end"></p>
    </xsl:template>
    <xsl:template match="regional">
        <table>
            <tbody>
                <tr>
                    <th width="25%">Region</th>
                    <th width="15%">Presence</th>
                    <th width="30%">Comments</th>
                    <th width="10%">Annex II</th>
                    <th width="10%">Annex IV</th>
                    <th width="10%">Status</th>
                </tr>
                <xsl:apply-templates select="region" />
            </tbody>
        </table>
    </xsl:template>
    <xsl:template match="region">
        <tr>
            <td>
                <xsl:value-of select="code/@desc" /> (<xsl:value-of select="code" />)
            </td>
            <td>
                <xsl:value-of select="presence/@desc" /> (<xsl:value-of select="presence" />)
            </td>
            <td>
                <xsl:apply-templates select="comments" />
            </td>
            <td>
                <xsl:apply-templates select="annex_ii" />
            </td>
            <td>
                <xsl:apply-templates select="annex_iv" />
            </td>
            <td>
                <xsl:if test="ms_added='true'">
                    <xsl:attribute name="style">
                        background-color:#347C17;color:#FFFFFF
                    </xsl:attribute>
                    New
                </xsl:if>
                <xsl:if test="ms_added='false' and predefined='false'">
                    <xsl:attribute name="style">
                        background-color:#F87217;color:#FFFFFF
                    </xsl:attribute>
                    Changed
                </xsl:if>
                <xsl:if test="ms_added='false' and predefined='true'">
                    Predefined
                </xsl:if>
            </td>
        </tr>
    </xsl:template>
    <xsl:template match="comments">
        <xsl:if test="string-length(.)=0">
            N/A
        </xsl:if>
        <xsl:if test="string-length(.)!=0">
            <xsl:call-template name="break">
                <xsl:with-param name="text" select="." />
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
    <!-- Replaces line breaks with <br/> tags -->
    <xsl:template name="break">
        <xsl:param name="text" select="." />
        <xsl:choose>
            <xsl:when test="contains($text, '&#10;')">
                <xsl:value-of select="substring-before($text, '&#10;')" />
                <br />
                <xsl:call-template name="break">
                    <xsl:with-param name="text" select="substring-after($text, '&#10;')" />
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$text" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="boolean-string">
        <xsl:param name="text" select="." />
        <xsl:param name="out-text" />
        <xsl:choose>
            <xsl:when test="$text='true'">
                <xsl:value-of select="$out-text" />
            </xsl:when>
            <xsl:otherwise />
        </xsl:choose>
    </xsl:template>
    <xsl:template match="*">
        <xsl:value-of select="." />
    </xsl:template>
</xsl:stylesheet>