View stylesheet

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

<!--
    Document   : dir20081ec_html.xsl.xsl
    Created on : 17 October 2011, 12:13
    Author     : Fazal_Miah
    Description:
        Purpose of transformation follows.
-->

<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">20081ec</xsl:variable>

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


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

    <xsl:template match="response">
        <html>
            <head>
                <title>
                    Factsheet of IPPC Module 1 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; }
                .tophead, .questionid { background-color:#CCCCCC; }
                </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="*">
        <tr>
            <th class="questionid"><xsl:value-of select="local-name()"/></th>
            <xsl:variable name="questionid" select="local-name()"/>
            <xsl:choose>
                <xsl:when test="$labels/label[@id=$questionid] != ''">
                    <th><xsl:value-of select="$labels/label[@id=$questionid]"/></th>
                </xsl:when>
                <xsl:otherwise>
                    <th><xsl:value-of select="local-name()"/></th>
                </xsl:otherwise>
            </xsl:choose>
            <td><xsl:value-of select="text()"/></td>
        </tr>
        
        <xsl:for-each select="*">
            <tr>
             <xsl:choose>
                <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: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>
                      <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="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>