View stylesheet

XML schema
Output type HTML
Description HTML preview
XSL file HTML_preview_bdr_test.xsl (Last modified: 09 Mar 2016 16:02 )
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/1999/xhtml" version="1.0"
                xmlns:ext="http://exslt.org/common"
                exclude-result-prefixes="xml">
    <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:preserve-space elements="published reasons-specify"/>

    <!-- variables -->
    <xsl:variable name="isProducer" select="/ODSReporting/GeneralReportData/Company/Actor/Producer"/>
    <xsl:variable name="isImporter" select="/ODSReporting/GeneralReportData/Company/Actor/Importer"/>
    <xsl:variable name="isExporter" select="/ODSReporting/GeneralReportData/Company/Actor/Exporter"/>
    <xsl:variable name="isPauUser" select="/ODSReporting/GeneralReportData/Company/Actor/ProcessAgent"/>
    <xsl:variable name="isFdstUser" select="/ODSReporting/GeneralReportData/Company/Actor/Feedstock"/>
    <xsl:variable name="isDestructor" select="/ODSReporting/GeneralReportData/Company/Actor/Destruction"/>
    <xsl:variable name="noReporting" select="/ODSReporting/GeneralReportData/Company/Actor/NoReporting"/>
    <xsl:variable name="referenceYear" select="/ODSReporting/GeneralReportData/TransactionYear"/>

    <xsl:template match="ODSReporting">
        <html>
            <!--xsl:attribute name="xml:lang"><xsl:value-of select="@xml:lang" /></xsl:attribute-->
            <head>
                <title>Factsheet</title>
                <style type="text/css"><![CDATA[


    img {
        border: 2px solid #ccc;
        margin: 10px;
    }
    h1 {
        font-family: arial, verdana, sans-serif;
        font-size: 160%;
        border-bottom: 1px solid #999999;
    }
    h2 {
        font-size: 120%;
        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;
        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;
        padding: 2px 2px 2px 2px;
    }
    .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;
    }

    sup {
        font-size:75%
    }

    .metadata_table tr th:first-child{
        width:150px;
    }
    .metadata_table td{
        width:350px;
    }
    .total{
        font-weight:bold;
        color: black;
        background-color: #bbb;
        border: 1px solid #fff;
    }
    .num_cell{
        text-align:right;
        background-color: #FFFFE0;
    }
    .substance_cell{
        text-align:center;
        font-weight:bold;
    }
    .row_height{
        height: 1em;
    }
    .bold{
        font-weight:bold;
    }
    ]]>
                </style>
            </head>
            <body>
                <h1>Report on the Ozone depleting substances</h1>
                <xsl:apply-templates/>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="GeneralReportData">
        <table class="metadata_table">
            <tr>
                <th>Report status</th>
                <td>
                    <span>
                        <xsl:attribute name="style">
                            <xsl:choose>
                                <xsl:when test="@status='submitted'">color:green</xsl:when>
                                <xsl:when test="@status='confirmed'">color:orange</xsl:when>
                                <xsl:otherwise>color:red</xsl:otherwise>
                            </xsl:choose>
                            ;font-weight:bold
                        </xsl:attribute>
                        <xsl:choose>
                            <xsl:when test="@status='incomplete'">Incomplete</xsl:when>
                            <xsl:when test="@status='confirmed'">In progress</xsl:when>
                            <!--	<xsl:value-of select="concat('Report not certified; Company info: ',@status)"/> -->
                            <xsl:when test="@status='submitted'">Submitted</xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="@status"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </span>
                </td>
            </tr>
            <xsl:if test="@status='submitted'">
                <tr>
                    <th>Date of Submission</th>
                    <td>
                        <xsl:value-of select="SubmissionDate"/>
                    </td>
                </tr>
            </xsl:if>
        </table>

        <xsl:apply-templates mode="general"/>
    </xsl:template>

    <xsl:template match="SubmissionDate|TransactionYear" mode="general"/>

    <xsl:template match="Company" mode="general">

        <h2>1. Reporting undertaking</h2>
        <table class="metadata_table">
            <tr>
                <th>ODS number</th>
                <td>
                    <xsl:value-of select="CompanyId"/>
                </td>
            </tr>
            <tr>
                <th>Company Name</th>
                <td>
                    <xsl:value-of select="CompanyName"/>
                </td>
            </tr>
            <tr>
                <th>Company Address</th>
                <td>
                    <xsl:value-of select="PostalAddress/StreetAddress"/>
                </td>
            </tr>
            <tr>
                <th></th>
                <td>
                    <xsl:value-of select="PostalAddress/City"/>
                    <xsl:if test="string-length(PostalAddress/Region) &gt; 0">,
                        <xsl:value-of select="PostalAddress/Region"/>
                    </xsl:if>
                </td>
            </tr>
            <tr>
                <th>Region</th>
                <td>
                    <xsl:value-of select="PostalAddress/Region"/>
                </td>
            </tr>
            <tr>
                <th>Postal Code</th>
                <td>
                    <xsl:value-of select="PostalAddress/PostalCode"/>
                </td>
            </tr>
            <tr>
                <th>Country</th>
                <td>
                    <xsl:value-of select="Country"/>
                </td>
            </tr>
            <tr>
                <th>EORI number</th>
                <td>
                    <xsl:value-of select="EoriCode"/>
                </td>
            </tr>
            <tr>
                <th>VAT number</th>
                <td>
                    <xsl:value-of select="VatCode"/>
                </td>
            </tr>
            <xsl:for-each select="ContactInfo">
                <tr>
                    <td colspan="2" class="row_height"/>
                </tr>
                <tr>
                    <th class="transactionColum">Contact Person
                        <xsl:if test="count(../ContactInfo) &gt; 1">(<xsl:value-of select="position()"/>)
                        </xsl:if>
                    </th>
                    <td class="generalReportDataColum">
                        <xsl:value-of select="ContactPerson"/>
                    </td>
                </tr>
                <tr>
                    <th class="transactionColum">Phone Number</th>
                    <td class="generalReportDataColum">
                        <xsl:value-of select="Telephone"/>
                    </td>
                </tr>
                <tr>
                    <th class="transactionColum">Fax Number</th>
                    <td class="generalReportDataColum">
                        <xsl:value-of select="FaxNumber"/>
                    </td>
                </tr>
                <tr>
                    <th class="transactionColum">Email Address</th>
                    <td class="generalReportDataColum">
                        <xsl:value-of select="Email"/>
                    </td>
                </tr>
            </xsl:for-each>
            <tr>
                <td colspan="2">
                    <span style="color:red;font-weight:bold">
                        <xsl:attribute name="style">
                            <xsl:choose>
                                <xsl:when test="@status='confirmed' or @status='submitted' ">color:green</xsl:when>
                                <xsl:otherwise>color:red</xsl:otherwise>
                            </xsl:choose>
                            ;font-weight:bold
                        </xsl:attribute>
                        <xsl:value-of select="@status"/>
                    </span>
                </td>
            </tr>
        </table>
        <table class="metadata_table">
            <tr>
                <th>Transaction Year</th>
                <td>
                    <xsl:value-of select="../TransactionYear"/>
                </td>
            </tr>
            <tr>
                <th>Activities</th>
                <td>
                    <xsl:if test="Actor/Producer='true'">
                        <div>Producer</div>
                    </xsl:if>
                    <xsl:if test="Actor/Importer='true'">
                        <div>Importer</div>
                    </xsl:if>
                    <xsl:if test="Actor/Exporter='true'">
                        <div>Exporter</div>
                    </xsl:if>
                    <xsl:if test="Actor/Destruction='true'">
                        <div>Destruction</div>
                    </xsl:if>
                    <xsl:if test="Actor/ProcessAgent='true'">
                        <div>Process Agent use</div>
                    </xsl:if>
                    <xsl:if test="Actor/Feedstock='true'">
                        <div>Feedstock use</div>
                    </xsl:if>
                    <xsl:if test="Actor/NoReporting='true'">
                        <div>Not obliged to report (NIL report)</div>
                    </xsl:if>
                </td>
            </tr>
        </table>
    </xsl:template>
    <xsl:template match="ODSSubstances">
        <xsl:if test="$noReporting='false' or count(ODSSubstances/Substance[string-length(Code) &gt; 0]) &gt; 0">
        <h2>2. Definition of substances</h2>
        <table>
            <xsl:apply-templates/>
        </table>
        </xsl:if>
    </xsl:template>
    <xsl:template match="Substance">
        <tr>
            <td>
                <xsl:value-of select="Code"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template match="ODSQuantities">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="TotalProduction">
        <xsl:if test="$isProducer='true' or count(ProductionQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0">
            <h2>3. Total production</h2>
            <table>
                <tr>
                    <th align="center" width="200px">Use</th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <tr>
                    <xsl:apply-templates/>

                    <td style="text-align:right;font-weight:bold;">
                        <xsl:attribute name="colspan">
                            <xsl:value-of select="1"/>
                        </xsl:attribute>
                        Total
                    </td>
                    <xsl:for-each select="//ODSSubstances/Substance">
                        <xsl:variable name="substance">
                            <xsl:value-of select="Code"/>
                        </xsl:variable>
                        <td align="right" class="total">
                            <xsl:value-of
                                    select="format-number(sum(//ODSQuantities/TotalProduction/ProductionQuantity[ not (Subject/@usetype = 'emissions during production') ]/Quantity/Value[../SubstanceCode=$substance and string-length(.) &gt; 0 and (number(.) &gt; 0 or number(.) &lt;= 0)]),'#')"/>
                        </td>


                    </xsl:for-each>
                </tr>
            </table>
        </xsl:if>
    </xsl:template>


    <xsl:template match="ProductionQuantity">
        <tr>
            <xsl:apply-templates select="Subject"/>
            <xsl:for-each select="Quantity">
                <xsl:apply-templates select="Value"/>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template match="CompanyQuantity">
        <xsl:if test="Subject/@usetype != ''">
            <tr>
                <xsl:apply-templates select="Company"/>
                <xsl:apply-templates select="Subject"/>
                <xsl:for-each select="Quantity">
                    <xsl:apply-templates select="Value"/>
                </xsl:for-each>
            </tr>
        </xsl:if>
    </xsl:template>
    <xsl:template match="Company">
        <xsl:variable name="companyName">
            <xsl:value-of select="CompanyName"/>
            <xsl:if test="string-length(CompanyName) &gt; 0">;</xsl:if>
        </xsl:variable>
        <xsl:variable name="companyAddress">
            <xsl:value-of select="CompanyAddress"/>
            <xsl:if test="string-length(CompanyAddress) &gt; 0">;</xsl:if>
        </xsl:variable>
        <td>
            <xsl:value-of select="$companyName"/><xsl:value-of select="$companyAddress"/><xsl:value-of
                select="Country/@desc"/>
        </td>
    </xsl:template>

    <xsl:template match="ImportQuantity">
        <tr>
            <xsl:apply-templates select="Subject"/>
            <td>
                <xsl:value-of select="CustomsProcedure"/><xsl:value-of select="Company/Country/@desc"/>
            </td>
            <td>
                <xsl:value-of select="Country/@desc"/>
            </td>

            <xsl:for-each select="Quantity">
                <xsl:apply-templates select="Value"/>
            </xsl:for-each>
        </tr>
    </xsl:template>


    <xsl:template match="StockQuantity">
        <tr>
            <td>
                <xsl:call-template name="DateLabel">
                    <xsl:with-param name="date">
                        <xsl:value-of select="./@date"/>
                    </xsl:with-param>
                </xsl:call-template>
                <xsl:value-of select="Subject/@usetype"/>
            </td>
            <xsl:for-each select="Quantity">
                <xsl:apply-templates select="Value"/>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template match="Quantity" mode="comments">
        <xsl:if test="string-length(Description) &gt; 0">
            <xsl:variable name="datelabel">
                <xsl:call-template name="DateLabel">
                    <xsl:with-param name="date">
                        <xsl:value-of select="../@date"/>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:variable>
            <xsl:variable name="uselabel">
                <xsl:value-of select="concat($datelabel, ' ', ../Subject/@usetype) "/>
            </xsl:variable>
            <tr>
                <td>
                    <xsl:value-of select="SubstanceCode"/>
                </td>
                <td>
                    <xsl:value-of select="$uselabel"/>
                </td>
                <td class="num_cell">
                    <xsl:value-of select="Value"/>
                </td>
                <td>
                    <xsl:value-of select="Description"/>
                </td>
            </tr>
        </xsl:if>
    </xsl:template>

    <xsl:template match="RecycledReclaimedQuantity">
        <tr>
            <xsl:apply-templates select="Subject"/>
            <xsl:for-each select="Quantity">
                <xsl:apply-templates select="Value"/>
            </xsl:for-each>
        </tr>
    </xsl:template>
    <xsl:template match="Subject">
        <td>
            <xsl:choose>
                <!--
          <xsl:when test=".!='' and ./@usetype!='other'">
            <xsl:value-of select="."/>
          </xsl:when>
          -->
                <xsl:when test="./@usetype='recycled'">Total quantity recycled</xsl:when>
                <xsl:when test="./@usetype='reclaimed'">Total quantity reclaimed</xsl:when>
                <xsl:when test=".!=''">
                    <xsl:value-of select="./@usetype"/>:<xsl:text> </xsl:text><xsl:value-of select="."/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="./@usetype"/>
                </xsl:otherwise>
            </xsl:choose>
        </td>
    </xsl:template>


    <xsl:template match="ExportQuantity">
        <tr>
            <xsl:apply-templates select="Subject"/>
            <td>
                <xsl:value-of select="Country/@desc"/>
            </td>
            <xsl:for-each select="Quantity">
                <xsl:apply-templates select="Value"/>
            </xsl:for-each>
        </tr>
    </xsl:template>
    <xsl:template match="SaleEUQuantity">
        <tr>
            <xsl:apply-templates select="Company"/>
            <xsl:apply-templates select="Subject"/>
            <xsl:for-each select="Quantity">
                <xsl:apply-templates select="Value"/>
            </xsl:for-each>
        </tr>
    </xsl:template>


    <xsl:template match="IndustrialRationalisation">
        <xsl:if test="$isProducer='true' or count(CompanyQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0">
            <h2>4. Production under industrial rationalisation</h2>
            <table>
                <tr>
                    <th width="250px">Transferring undertaking</th>
                    <th width="200px">Use</th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <xsl:apply-templates/>

                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">2</xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                </xsl:call-template>
            </table>
        </xsl:if>
    </xsl:template>
    <xsl:template match="RecycledReclaimed">
        <xsl:if test="$isProducer='true' or count(RecycledReclaimedQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0">
            <h2>5. Recycling and reclamation by producers</h2>
            <table>
                <tr>
                    <th width="250px">Recycling and reclamation (for any uses inside or outside EU)</th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <xsl:apply-templates/>
                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">1</xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                </xsl:call-template>
            </table>
        </xsl:if>
    </xsl:template>
    <xsl:template match="TotalRecieved">
        <xsl:if test="$noReporting='false' or count(CompanyQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0">
            <h2>6. Quantities received from undertakings in the EU (e.g. purchases)</h2>
            <table>
                <tr>
                    <th width="250px">Supplier</th>
                    <th width="200px">Use</th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <xsl:apply-templates/>
                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">2</xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                </xsl:call-template>
            </table>
        </xsl:if>
    </xsl:template>
    <xsl:template match="TotalImports">
        <xsl:if test="$isImporter='true' or count(ImportQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0">
            <h2>7. Total imports from countries or territories outside EU.</h2>
            <table>
                <tr>
                    <th width="200px">Use</th>
                    <th width="250px">Customs procedure</th>
                    <th width="150px">Source country</th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <xsl:apply-templates/>
                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">3</xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                </xsl:call-template>
            </table>
        </xsl:if>
    </xsl:template>
    <xsl:template match="TotalStocks">
        <xsl:if test="$noReporting = 'false' or count(StockQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0">
            <h2>8. Total stocks</h2>
            <table>
                <tr>
                    <th width="200px">Total stocks at the beginning / end of reporting year</th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <xsl:apply-templates select="StockQuantity[@date = '01-01']"/>

                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">1</xsl:with-param>
                    <xsl:with-param name="date">01-01</xsl:with-param>
                    <xsl:with-param name="sumtext">
                        <xsl:call-template name="DateLabel">
                            <xsl:with-param name="date">01-01</xsl:with-param>
                        </xsl:call-template>
                        Total
                    </xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                </xsl:call-template>

                <xsl:apply-templates select="StockQuantity[@date = '12-31']"/>
                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">1</xsl:with-param>
                    <xsl:with-param name="date">12-31</xsl:with-param>
                    <xsl:with-param name="sumtext">
                        <xsl:call-template name="DateLabel">
                            <xsl:with-param name="date">12-31</xsl:with-param>
                        </xsl:call-template>
                        Total
                    </xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                </xsl:call-template>
                <tr>
                    <td align="right;font-weight:bold">Stocks consumed</td>
                    <xsl:for-each select="//ODSSubstances/Substance">
                        <xsl:variable name="code">
                            <xsl:value-of select="Code"/>
                        </xsl:variable>
                        <td align="right" class="total">

                            <xsl:variable name="consumed">
                                <xsl:value-of
                                        select="format-number(sum(//ODSQuantities/TotalStocks/StockQuantity/Quantity/Value[../SubstanceCode=$code and ../../@date = '01-01' and string-length(.) &gt; 0 and (number(.) &gt; 0 or number(.) &lt;= 0)])-
                                    sum(//ODSQuantities/TotalStocks/StockQuantity/Quantity/Value[../SubstanceCode=$code and ../../@date = '12-31' and string-length(.) &gt; 0 and (number(.) &gt; 0 or number(.) &lt;= 0)]),'#')"/>
                            </xsl:variable>

                            <xsl:choose>
                                <xsl:when test="$consumed &gt; 0">
                                    <xsl:value-of select="$consumed"/>
                                </xsl:when>
                                <xsl:otherwise>0</xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </xsl:for-each>
                </tr>
            </table>
            <xsl:if test="count(StockQuantity/Quantity[string-length(Description)&gt;0]) &gt; 0">
                <span style="font-weight:bold">
                    <sup>*</sup>
                    Values have related comments that are listed in the table below
                </span>
                <h2>Comments with relation to the stocks</h2>
                <table>
                    <tr>
                        <th>Substance</th>
                        <th>Date Usetype</th>
                        <th>Quantity</th>
                        <th>Comment</th>
                    </tr>
                    <xsl:apply-templates mode="comments"/>
                </table>
            </xsl:if>
        </xsl:if>
    </xsl:template>
    <xsl:template match="ProducerStocks">
        <xsl:if test="$isImporter='true' or count(StockQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0">
            <h2>9. Stocks for selected uses held by producers</h2>
            <table>
                <tr>
                    <th align="center" width="200px">Stocks reported in table 8 resulting from production in the
                        reporting year:
                    </th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <xsl:apply-templates/>
                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">1</xsl:with-param>
                    <xsl:with-param name="date">12-31</xsl:with-param>
                    <xsl:with-param name="sumtext">
                        <xsl:call-template name="DateLabel">
                            <xsl:with-param name="date">12-31</xsl:with-param>
                        </xsl:call-template>
                        Total
                    </xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                </xsl:call-template>

            </table>
        </xsl:if>
    </xsl:template>

    <xsl:template match="SalesEUMarket">
        <xsl:if test="$isImporter='true' or $isProducer='true' or $isExporter='true' or $isPauUser='true' or $isFdstUser='true' or count(SaleEUQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0">
            <h2>10. Placing on the EU market during the reporting year (sales etc.)</h2>
            <table>
                <tr>
                    <th align="center">Recipient</th>
                    <th align="center">Use</th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <xsl:apply-templates/>
                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">2</xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                </xsl:call-template>

            </table>
        </xsl:if>
    </xsl:template>

    <xsl:template match="ExportFromEU">
        <xsl:if test="$isExporter='true' or count(ExportQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0">
            <h2>11. Exports to countries and territories outside EU</h2>
            <table>
                <tr>
                    <th align="center">Use</th>
                    <th align="center">Destination country</th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <xsl:apply-templates/>
                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">2</xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                </xsl:call-template>

            </table>
        </xsl:if>
    </xsl:template>

    <xsl:template match="PauFdst">
        <xsl:if test="$isPauUser='true' or $isFdstUser='true' or count(ProcessQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0">
            <h2>12. Feedstock and process agent use within the reporting undertaking</h2>
            <table>
                <tr>
                    <th colspan="2" align="center">Processes</th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <xsl:apply-templates select="ProcessQuantity"/>

                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">2</xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                    <xsl:with-param name="subtable">MakeUp</xsl:with-param>
                    <xsl:with-param name="sumtext">Total Make-up</xsl:with-param>
                </xsl:call-template>

                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">2</xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                    <xsl:with-param name="subtable">Emissions</xsl:with-param>
                    <xsl:with-param name="sumtext">Total Emission</xsl:with-param>
                </xsl:call-template>
            </table>
            <xsl:if test="count(ProcessQuantity/*/Quantity[string-length(Description)&gt;0]) &gt; 0">
                <span style="font-weight:bold">
                    <sup>*</sup>
                    Values have related comments that are listed in the table below
                </span>
                <h2>Comments with relation to the use within the company</h2>
                <table>
                    <tr>
                        <th>Substance</th>
                        <th>Process</th>
                        <th>Usetype</th>
                        <th>Quantity</th>
                        <th>Estimated value</th>
                    </tr>
                    <xsl:for-each select="ProcessQuantity/MakeUp/Quantity">
                        <xsl:if test="string-length(Description) &gt; 0">
                            <tr>
                                <td>
                                    <xsl:value-of select="SubstanceCode"/>
                                </td>
                                <td>
                                    <xsl:value-of select="../../Process"/>
                                </td>
                                <td>Make-up</td>
                                <td class="num_cell">
                                    <xsl:value-of select="Value"/>
                                </td>
                                <td>
                                    <xsl:value-of select="EstimatedValue"/>
                                </td>
                            </tr>
                        </xsl:if>
                    </xsl:for-each>
                    <xsl:for-each select="ProcessQuantity/Emissions/Quantity">
                        <xsl:if test="string-length(Description) &gt; 0">
                            <tr>
                                <td>
                                    <xsl:value-of select="SubstanceCode"/>
                                </td>
                                <td>
                                    <xsl:value-of select="../../Process"/>
                                </td>
                                <td>Emission</td>
                                <td class="num_cell">
                                    <xsl:value-of select="Value"/>
                                </td>
                                <td>
                                    <xsl:value-of select="EstimatedValue"/>
                                </td>
                            </tr>
                        </xsl:if>
                    </xsl:for-each>
                </table>
            </xsl:if>
            <xsl:apply-templates select="Comments"/>
        </xsl:if>
    </xsl:template>

    <xsl:template match="UseWithinReporting">
        <xsl:if test="$noReporting='false'">
        <h2>13. Use within the reporting undertaking (no longer applicable)</h2>
        <table>
            <tr/>
        </table>
        </xsl:if>
    </xsl:template>

    <xsl:template match="ReporterUses">
        <xsl:if test="$referenceYear &lt; 2015 and ($isImporter='true' or $isProducer='true' or $isExporter='true' or count(UsedQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0)">
            <h2>13. Use within the reporting undertaking</h2>
            <table>
                <tr>
                    <th align="center">Use</th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <xsl:apply-templates/>
                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">1</xsl:with-param>
                    <xsl:with-param name="tablename"><xsl:value-of select="name(.)"/></xsl:with-param>
                </xsl:call-template>

            </table>
        </xsl:if>
    </xsl:template>

    <xsl:template match="UsedQuantity">
        <tr>
            <xsl:apply-templates select="Subject"/>
            <xsl:for-each select="Quantity">
                <xsl:apply-templates select="Value"/>
            </xsl:for-each>
        </tr>
    </xsl:template>


    <xsl:template match="Destruction">
        <xsl:if test="$isDestructor='true' or count(DestructionQuantity//Quantity[string-length(Value) &gt; 0]) &gt; 0">
            <h2>14. Quantities destroyed at your facility</h2>
            <table>
                <tr>
                    <th align="center">Destruction technology</th>
                    <xsl:call-template name="SubstancesHeaderCols"/>
                </tr>
                <xsl:apply-templates/>

                <xsl:call-template name="QuantitySumRow">
                    <xsl:with-param name="cols">1</xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="name(.)"/>
                    </xsl:with-param>
                </xsl:call-template>
            </table>
        </xsl:if>
    </xsl:template>

    <xsl:template match="Comments">
        <xsl:if test="string-length(.) &gt; 0">
            <h2>Comments</h2>
            <div>
                <xsl:value-of select="."/>
            </div>
        </xsl:if>
    </xsl:template>

    <xsl:template match="DestructionQuantity">
        <tr>
            <td>
                <xsl:value-of select="DestructionTechnology"/>
            </td>
            <xsl:for-each select="Quantity">
                <xsl:apply-templates select="Value"/>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template match="ProcessQuantity">
        <xsl:variable name="process">
            <xsl:value-of select="Process"/>
        </xsl:variable>
        <xsl:variable name="comment">
            <xsl:value-of select="concat(' ' , Process/@comment)"/>
        </xsl:variable>
        <xsl:variable name="containment">
            <xsl:choose>
            <xsl:when test="string-length(Process/@containment) > 0">
                     <xsl:value-of select="concat(' Containment method : ', Process/@containment)"/>
                </xsl:when>
            </xsl:choose>

        </xsl:variable>

        <tr>
            <td rowspan="4">
                <xsl:value-of select="concat(substring-after($process,' '), $comment, $containment )"/>
            </td>
            <td class="bold">Make-up</td>
            <xsl:for-each select="MakeUp/Quantity">
                <xsl:apply-templates select="Value"/>
            </xsl:for-each>
        </tr>
        <td>Estimation next year</td>
        <xsl:for-each select="MakeUp/Quantity">
            <xsl:apply-templates select="EstimatedValue "/>
        </xsl:for-each>
        <tr>
            <td class="bold">Emission</td>
            <xsl:for-each select="Emissions/Quantity">
                <xsl:apply-templates select="Value"/>
            </xsl:for-each>
        </tr>
        <tr>
            <td>Estimation next year</td>
            <xsl:for-each select="Emissions/Quantity">
                <xsl:apply-templates select="EstimatedValue "/>
            </xsl:for-each>
        </tr>
    </xsl:template>
    <xsl:template match="Process">
        <td rowspan="4">
            <xsl:value-of select="."/>
        </td>
    </xsl:template>

    <xsl:template name="QuantitySumRow">
        <xsl:param name="tablename"/>
        <xsl:param name="date"/>
        <xsl:param name="sumtext"/>
        <xsl:param name="cols"/>
        <xsl:param name="subtable"/>
        <tr>
            <td style="text-align:right;font-weight:bold;">
                <xsl:attribute name="colspan">
                    <xsl:value-of select="$cols"/>
                </xsl:attribute>
                <xsl:choose>
                    <xsl:when test="$sumtext=''">Total</xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="$sumtext"/>
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <xsl:for-each select="//ODSSubstances/Substance">
                <xsl:variable name="code">
                    <xsl:value-of select="Code"/>
                </xsl:variable>
                <xsl:call-template name="QuantitySumCol">
                    <xsl:with-param name="substancecode">
                        <xsl:value-of select="$code"/>
                    </xsl:with-param>
                    <xsl:with-param name="tablename">
                        <xsl:value-of select="$tablename"/>
                    </xsl:with-param>
                    <xsl:with-param name="subtable">
                        <xsl:value-of select="$subtable"/>
                    </xsl:with-param>
                    <xsl:with-param name="date">
                        <xsl:value-of select="$date"/>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="QuantitySumCol">
        <xsl:param name="tablename"/>
        <xsl:param name="substancecode"/>
        <xsl:param name="subtable"/>
        <xsl:param name="date"/>
        <td align="right" class="total">
            <xsl:choose>
                <xsl:when test="$subtable != ''">
                    <xsl:value-of
                            select="format-number(sum(//ODSQuantities/*[name()=$tablename]/*/*[name()=$subtable]/Quantity/Value[../SubstanceCode=$substancecode and string-length(.) &gt; 0 and (number(.) &gt; 0 or number(.) &lt;= 0)]),'#')"/>
                </xsl:when>
                <xsl:when test="$date != ''">
                    <xsl:value-of
                            select="format-number(sum(//ODSQuantities/*[name()=$tablename]/*/Quantity/Value[../SubstanceCode=$substancecode and (substring(../../@date, 6,5) = $date or ../../@date = $date)  and string-length(.) &gt; 0 and (number(.) &gt; 0 or number(.) &lt;= 0)]),'#')"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of
                            select="format-number(sum(//ODSQuantities/*[name()=$tablename]/*/Quantity/Value[../SubstanceCode=$substancecode and string-length(.) &gt; 0  and (number(.) &gt; 0 or number(.) &lt;= 0)]),'#')"/>
                </xsl:otherwise>
            </xsl:choose>
        </td>
    </xsl:template>

    <xsl:template name="DateLabel">
        <xsl:param name="date"/>
        <xsl:choose>
            <xsl:when test="$date = '01-01'">
                At 01 January
            </xsl:when>
            <xsl:when test="$date = '12-31'">
                At 31 December
            </xsl:when>
            <xsl:otherwise>
                At
                <xsl:value-of select="$date"/>
            </xsl:otherwise>

        </xsl:choose>
    </xsl:template>

    <xsl:template name="SubstancesHeaderCols">
        <xsl:for-each select="//ODSSubstances/Substance">
            <th width="100px" class="substance_cell">
                <xsl:value-of select="Code"/>
            </th>
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="Value">
        <td class="num_cell">

            <xsl:value-of select="."/>

        </td>
    </xsl:template>
    <xsl:template match="EstimatedValue">
        <td class="num_cell">
            <xsl:value-of select="."/>
        </td>
    </xsl:template>
    <xsl:template match="*">
    </xsl:template>
</xsl:stylesheet>