View stylesheet

XML schema http://dd.eionet.europa.eu/schemas/ippc-wi/ippc_module2_schema.xsd
Output type HTML
Description HTML Factsheet - IPPC Module 2
XSL file ippc_module2_html.xsl (Last modified: 01 Jun 2012 13:13 )
<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : ippc_module2_html.xsl
    Created on : 17 October 2011, 10:47
    Author     : Fazal_Miah
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <!-- TODO customize transformation rules 
         syntax recommendation http://www.w3.org/TR/xslt 
    -->
    <xsl:output method="html" encoding="utf-8"/>
    <xsl:param name="xml_folder_uri"/>
    <xsl:variable name="directiveid">ippc_module2</xsl:variable>
    <xsl:variable name="directiveidfull" select="concat('Quest', $directiveid, '-')"/>

    <xsl:variable name="labels" select="document('http://webqdev.eionet.europa.eu/xml/ippc_module2_xsl_labels.xml')/labels/labelSet[@xml:lang='en']"/>



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

    <xsl:template match="response">
        <html>
            <head>
                <title>
                    Factsheet of IPPC Module 2 (ELV/BAT) delivery
                </title>

                <style type="text/css">
                table { border: 1px solid black; border-collapse: collapse; width:100%;}
                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">
        <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: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-->
                
            </tr>
        </xsl:for-each>
    </xsl:template>

    <xsl:template name="display_table_heading">

         Installation Type: <xsl:value-of select="@type"/> |
         <xsl:choose>
            <xsl:when test="@type = 'metals-plastics'">
                Installation Code: <xsl:value-of select="q-1/q-1-2/q-1-2-1"/> |
                Installation Name: <xsl:value-of select="q-1/q-1-1/q-1-1-1"/>
            </xsl:when>
            <xsl:otherwise>
                Installation Code: <xsl:value-of select="q-5/q-5-2/q-5-2-1"/> |
                Installation Name: <xsl:value-of select="q-5/q-5-1-1"/>

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

    <xsl:template name="display_label_or_id">
        <!-- Remove directive id - directive id not included in new module 2 -->
        <xsl:variable name="questionid" select="local-name()"/>

        <!-- Get question label or id -->
        <xsl:choose>

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

    <xsl:template name="display_table">
        <table>
            <xsl:choose>
            <xsl:when test="contains(local-name(), 'test-checkbox')">
                
            </xsl:when>
            
            <xsl:otherwise>
            <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:otherwise>
            </xsl:choose>


            <xsl:for-each select="*">
                    <tr>
                      <xsl:choose>
                            <xsl:when test="*">

                                    <th colspan="3" class="newRow"><xsl:value-of select="local-name()" /></th>
                                
                            </xsl:when>
                           <xsl:otherwise>
                                <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>
                            </xsl:otherwise>
                       </xsl:choose>
                    </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:when test="contains(local-name(), '-row')">

                                <td colspan="3">
                                    <xsl:call-template name="display_table"/>
                                </td>
                            </xsl:when>
                            <xsl:when test="descendant::*">
                                <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_table_label_or_id"/></th>
                                <td><xsl:value-of select="text()" /></td>
                            </xsl:otherwise>
                          </xsl:choose>
                        </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/label[@id=$questionid] != ''">

                <xsl:value-of select="$labels/label[@id=$questionid]"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="local-name()"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


</xsl:stylesheet>