XML schema |
http://dd.eionet.europa.eu/schemas/CO2-monitoring-cars_2014/cars-aggregated.xsd
|
---|---|
Output type | HTML |
Description | HTML table |
XSL file | cars_co2_aggregations_html_2014.xsl (Last modified: 28 Jan 2014 11:20 ) |
<?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$ For http://dd.eionet.europa.eu/schemas/CO2-monitoring-cars_2014/cars-aggregated.xsd --> <xsl:variable name="heading" select="'CO2 Emissions for cars - aggregated 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="aggregates/item"/> </table> </body> </html> </xsl:template> <xsl:template match="aggregates/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"> <xsl:variable name="rootAttributes" select="/aggregates/attribute::*"/> <xsl:for-each select="$attributes/attr"> <xsl:variable name="attrName" select="@name" /> <xsl:variable name="attrValue" select="$rootAttributes[name()=$attrName]" /> <tr> <th> <xsl:value-of select="@heading" /> </th> <td> <xsl:if test="$attrValue = ''"> </xsl:if> <xsl:value-of select="$attrValue"/> </td> </tr> </xsl:for-each> </table> </xsl:template> <xsl:variable name="elements"> <element name="ID" heading="ID" /> <element name="Mh" heading="EU Manufacturer Name" /> <element name="Man" heading="Manufacturer" /> <element name="MMS" heading="Manufacturer National" /> <element name="Rw" heading="# wheelbase" /> <element name="Rat1" heading="# axle value" /> <element name="Rat2" heading="# having an axle (other) value" /> <element name="Eav" heading="Average CO2 Emissions" /> <element name="Mav" heading="Average Mass" /> <element name="Fav" heading="Average Footprint" /> </xsl:variable> <xsl:variable name="attributes"> <attr name="Y" heading="Year" /> <attr name="MS" heading="Member State" /> <attr name="DS" heading="Data source" /> <attr name="FSP" heading="Percentage of E85 stations" /> <attr name="NFS" heading="Total number of fuel filling stations" /> <attr name="Rt" heading="Registrations" /> <attr name="Re" heading="Registrations with CO2 emission value" /> <attr name="Rm" heading="Registrations with mass value" /> </xsl:variable> </xsl:stylesheet>
European Environment Agency
Kgs. Nytorv 6, DK-1050 Copenhagen K, Denmark