View stylesheet

XML schema http://dd.eionet.europa.eu/schemas/CO2-monitoring-vans_2013/vans-detailed.xsd
Output type EXCEL
Description MS Excel
XSL file vans_co2_detailed_excel_2013.xsl (Last modified: 16 Jan 2013 16:13 )
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0" xmlns:office="http://openoffice.org/2000/office"
    xmlns:table="http://openoffice.org/2000/table" xmlns:text="http://openoffice.org/2000/text">
    <xsl:output method="xml"/>
    <!--
        $Id$
        For http://dd.eionet.europa.eu/schemas/CO2-monitoring-vans_2013/vans-detailed.xsd
    -->
    <xsl:variable name="heading" select="'CO2-vans-detailed'"/>
    <xsl:template match="VansDetails">
        <office:document-content xmlns:office="http://openoffice.org/2000/office"
            xmlns:table="http://openoffice.org/2000/table" office:version="1.0"
            xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:number="http://openoffice.org/2000/datastyle"
            xmlns:text="http://openoffice.org/2000/text" xmlns:fo="http://www.w3.org/1999/XSL/Format"
            xmlns:style="http://openoffice.org/2000/style">
            <office:automatic-styles>
                <style:style style:name="cell1" style:family="table-cell">
                    <style:properties fo:text-align="left"
                        fo:font-size="10pt" />
                </style:style>
                <style:style style:name="cell2" style:family="table-cell">
                    <style:properties fo:text-align="center"
                        fo:font-size="12pt" fo:font-style="italic" />
                </style:style>
                <style:style style:name="Heading1" style:family="table-cell">
                    <style:properties fo:text-align="left"
                        fo:font-size="10pt" fo:font-style="italic"
                        style:text-align-source="fix" fo:font-weight="bold" />
                </style:style>
                <style:style style:name="Heading2" style:family="table-cell">
                    <style:properties fo:text-align="center"
                        fo:font-size="10pt" fo:font-weight="bold" />
                </style:style>
                <style:style style:name="Heading3" style:family="table-cell">
                    <style:properties fo:text-align="Right"
                        fo:font-size="10pt" fo:font-weight="bold" style:column-width="5cm"/>
                </style:style>
            </office:automatic-styles>
            <office:body>
                <table:table>
                    <xsl:attribute name="table:name"><xsl:value-of select="$heading"/></xsl:attribute>
                    <table:table-columns>
                        <table:table-column
                            table:default-cell-value-type="number"
                            table:default-cell-style-name="cell1">
                            <xsl:attribute name="table:number-columns-repeated"><xsl:value-of
                                select="count($elements/element)" /></xsl:attribute>
                        </table:table-column>
                    </table:table-columns>
                    <!-- create header rows -->
                    <table:table-rows>
                        <xsl:apply-templates select="item" />
                    </table:table-rows>
                </table:table>
                <xsl:call-template name="metadata-table" />
            </office:body>
        </office:document-content>
    </xsl:template>
    <xsl:template match="item">
        <xsl:if test="position()=1">
            <xsl:call-template name="header" />
        </xsl:if>
        <xsl:variable name="vehicleRow" select="."/>
        <table:table-row>
            <xsl:for-each select="$elements/element">
                <xsl:variable name="elemName" select="@name"/>
                <xsl:variable name="elemValue" select="$vehicleRow/*[local-name() = $elemName]"/>
                <table:table-cell>
                    <text:p>
                        <xsl:value-of select="$elemValue"/>
                    </text:p>
                </table:table-cell>
            </xsl:for-each>
        </table:table-row>
    </xsl:template>
    <!-- a named template, which creates the table header row -->
    <xsl:template name="header">
        <table:table-header-rows>
            <table:table-row table:default-cell-value-type="string"
                table:default-cell-style-name="Heading2">
                <xsl:for-each select="$elements/element">
                    <table:table-cell>
                        <text:p>
                          <xsl:value-of select="@heading"/>
                        </text:p>
                    </table:table-cell>
                </xsl:for-each>
            </table:table-row>
        </table:table-header-rows>
    </xsl:template>

    <xsl:template name="metadata-table">
        <table:table>
            <xsl:attribute name="table:name">Metadata</xsl:attribute>
            <table:table-columns>
                <table:table-column
                    table:default-cell-value-type="string"
                    table:default-cell-style-name="Heading3" />
                <table:table-column
                    table:default-cell-value-type="string"
                    table:default-cell-style-name="cell1" />
            </table:table-columns>
            <table:table-rows>
                <table:table-row>
                    <table:table-cell table:style-name="Heading3">
                        <text:p>Year</text:p>
                    </table:table-cell>
                    <table:table-cell table:style-name="cell1">
                        <text:p>
                            <xsl:value-of select="/VansDetails/@Y" />
                        </text:p>
                    </table:table-cell>
                </table:table-row>
                <table:table-row>
                    <table:table-cell>
                        <text:p>Member State</text:p>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p>
                            <xsl:value-of select="/VansDetails/@MS" />
                        </text:p>
                    </table:table-cell>
                </table:table-row>
            </table:table-rows>
        </table: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="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="Cr" heading="Category Registered"/>
        <element name="R" heading="Registrations"/>
        <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 track of steered axle"/>
        <element name="At2" heading="Axle track 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"/>
        <element name="Z" heading="Electric energy consumption"/>
        <element name="IT" heading="Innovative technology"/>
        <element name="Er" heading="Emission reduction"/>
    </xsl:variable>

</xsl:stylesheet>