View stylesheet

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

<!--
    Document   : dir200076ec_html.xsl
    Created on : 20 October 2011, 15:22
    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">200076</xsl:variable>

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


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

    <xsl:template match="response">
        <html>
            <head>
                <title>
                    Factsheet of WI 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; height:32px;}
                .tophead, .questionid { background-color:#CCCCCC; }
                .newRow { background-color:#FCD5B4; height: 32px;}
                </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>
            <th><xsl:call-template name="display_label_or_id"/></th>
            <td><xsl:value-of select="text()"/></td>

        </tr>

        <xsl:for-each select="*">
            <tr>
             <xsl:choose>
                <xsl:when test="child::*">
                    <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_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:template name="display_table">
        <table>

            <caption><i><xsl:call-template name="display_table_label_or_id"/></i></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"><i><xsl:call-template name="display_table_label_or_id"/></i></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>