View stylesheet

XML schemas http://dd.eionet.europa.eu/schemas/CO2-monitoring-vans_2015/oem-vans-vin.xsd
Output type HTML
Description Show as simple table
XSL file vans_oem_detailed_html_2015.xsl (Last modified: 23 Feb 2015 13:52 )
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>
    <!--
        $Id: vans_oem_detailed_html_2015.xsl 18294 2015-02-23 12:51:25Z roug $
        For http://dd.eionet.europa.eu/schemas/CO2-monitoring-vans_2015/oem-vans-vin.xsd
    -->
    <xsl:variable name="heading" select="'CO2 Emissions for vans - detailed data'"/>

    <xsl:template match="/">
        <html>
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
                <title><xsl:value-of select="$heading"/></title>
                <style type="text/css">
                    table {
                        border-collapse:collapse;
                    }
                    td, th {
                        border:1px solid black; padding:2px;
                    }
                    #metadata th{
                        text-align:right;
                    }
                  </style>
            </head>
            <body>
                <h1><xsl:value-of select="$heading"/></h1>
                <xsl:call-template name="metadata-table"/>
                <br/>
                <table>
                    <xsl:apply-templates select="VansOemDetails/item"/>
                </table>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="VansOemDetails/item">
        <xsl:if test="position()=1">
            <xsl:call-template name="header"/>
        </xsl:if>
        <xsl:variable name="vehicleRow" select="."/>
        <tr>
            <xsl:for-each select="$elements/element">
                <xsl:variable name="elemName" select="@name"/>
                <xsl:variable name="elemValue" select="$vehicleRow/*[local-name() = $elemName]"/>
                <td>
                    <xsl:if test="$elemValue = ''"> </xsl:if>
                    <xsl:value-of select="$elemValue"/>
                </td>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="header">
        <tr>
            <xsl:for-each select="$elements/element">
                <th style="background-color:#87cefa">
                    <xsl:value-of select="@heading"/>
                </th>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="metadata-table">
        <table id="metadata">
            <tr>
                <th>Year</th>
                <td>2015</td>
            </tr>
        </table>
    </xsl:template>

    <xsl:variable name="elements">
        <element name="ID" heading="ID"/>
        <element name="VIN" heading="VIN"/>
        <element name="Mh" heading="EU Manufacturer Name"/>
        <element name="Man" heading="Manufacturer"/>
        <element name="Tan" heading="Type approval number"/>
        <element name="T" heading="Type"/>
        <element name="Va" heading="Variant"/>
        <element name="Ve" heading="Version"/>
        <element name="Mk" heading="Make"/>
        <element name="Cn" heading="Commercial name"/>
        <element name="Ct" heading="Category"/>
        <element name="M" heading="Mass"/>
        <element name="TPMLM" heading="Laden Mass"/>
        <element name="E" heading="Emissions"/>
        <element name="W" heading="Wheelbase"/>
        <element name="At1" heading="Axle width of steered axle"/>
        <element name="At2" heading="Axle width of other axle"/>
        <element name="Ft" heading="Fuel type"/>
        <element name="Fm" heading="Fuel mode"/>
        <element name="Ec" heading="Engine capacity"/>
        <element name="Ep" heading="Engine power"/>
    </xsl:variable>

</xsl:stylesheet>