View stylesheet

XML schema http://www.eionet.europa.eu/schemas/ippc-wi/dir20081elvbat_schema.xsd
Output type HTML
Description Simple HTML factsheet
XSL file dir20081elvbat_html.xsl (Last modified: 08 Dec 2009 14:33 )
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: dir20081elvbat_html.xsl 246 2009-07-23 16:35:36Z sebf $ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:output method="html" encoding="utf-8"/>
    <xsl:param name="xml_folder_uri"/>
    <xsl:variable name="directiveid">20081elvbat</xsl:variable>
    <xsl:variable name="directiveidfull" select="concat('Quest', $directiveid, '-')"/>
    <xsl:variable name="labels" select="document(concat($xml_folder_uri,concat('dir', $directiveid, '_xsl_labels.xml')))/labels/itemset[@xml:lang='en']"/>



    <xsl:template match="text()"/>

    <xsl:template match="Questionnaire">
        <html>
            <head>
                <title>
                    Factsheet of IPPC ELVBAT delivery
                </title>
                <style type="text/css">
                table { border: 1px solid black; border-collapse: collapse}
                table th, table td { text-align: left; border: 1px solid black; }
                table caption { border: 1px solid black; font-weight: bold; }
                .tophead, .questionid { background-color:#CCCCCC; }
                .newRow { background-color:#FCD5B4; }
                .newSite { background-color:#6cd06c; }
                </style>
            </head>
            <body>
                <table class="bluetable">
                    <col style="width:15%"/>
                    <col style="width:30%"/>
                    <col style="width:55%"/>
                    <tr class="tophead">
                        <th>Question ID</th>
                        <th>Question</th>
                        <th>Answer</th>
                    </tr>

                    <xsl:apply-templates/>
                </table>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="installation-combustion-row">
        <tr><th colspan="3" class="newSite"><xsl:call-template name="display_table_heading"/></th></tr>
        <xsl:for-each select="*">
            <tr>
                <xsl:choose>
                    <xsl:when test="contains(local-name(), '-table')">
                        <td colspan="3">
                            <xsl:call-template name="display_table"/>
                        </td>
                    </xsl:when>
                    <xsl:otherwise>
                        <th class="questionid"><xsl:value-of select="local-name()"/></th>
                        <th><xsl:call-template name="display_label_or_id"/></th>
                        <td><xsl:value-of select="text()"/></td>
                    </xsl:otherwise>
                </xsl:choose>
            </tr>
        </xsl:for-each>
    </xsl:template>

    <xsl:template name="display_table_heading">
         Installation Type: <xsl:value-of select="@status"/> |
         <xsl:choose>
            <xsl:when test="@status = 'lcp'">
                Installation Code: <xsl:value-of select="concat(Quest20081elvbat-q-1-2-Country, Quest20081elvbat-q-1-2-Range, '_', Quest20081elvbat-q-1-2-Amount)"/> |
                Installation Name: <xsl:value-of select="Quest20081elvbat-q-1-1"/>
            </xsl:when>
            <xsl:otherwise>
                Installation Code: <xsl:value-of select="concat(Quest20081elvbat-q2-1-2-Country, Quest20081elvbat-q2-1-2-Number)"/> |
                Installation Name: <xsl:value-of select="Quest20081elvbat-q2-1-1"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="display_label_or_id">
        <!-- Remove directive id -->
        <xsl:variable name="questionid" select="substring-after(local-name(),$directiveidfull)"/>

        <!-- Get question label or id -->
        <xsl:choose>
            <xsl:when test="$labels/item[@id=$questionid] != ''">
                <xsl:value-of select="$labels/item[@id=$questionid]"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="local-name()"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="display_table">
        <table>
            <caption><xsl:value-of select="local-name()" /></caption>
            <col style="width:15%"/>
            <col style="width:30%"/>
            <col style="width:55%"/>
            <tr class="tophead">
                <th>Question ID</th>
                <th>Question</th>
                <th>Answer</th>
            </tr>

            <xsl:for-each select="*">
                    <tr><th colspan="3" class="newRow"><xsl:value-of select="local-name()" /> <xsl:value-of select="position()" /></th></tr>
                    <xsl:for-each select="*">
                        <tr>
                            <th class="questionid"><xsl:value-of select="local-name()"/></th>
                            <th><xsl:call-template name="display_table_label_or_id"/></th>
                            <td><xsl:value-of select="text()" /></td>
                        </tr>
                    </xsl:for-each>
            </xsl:for-each>
        </table>
    </xsl:template>

    <xsl:template name="display_table_label_or_id">
        <!-- Remove directive id -->
        <xsl:variable name="questionid" select="local-name()"/>

        <!-- Get question label or id -->
        <xsl:choose>
            <xsl:when test="$labels/item[@id=$questionid] != ''">
                <xsl:value-of select="$labels/item[@id=$questionid]"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="local-name()"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

</xsl:stylesheet>