View stylesheet

XML schemas http://dd.eionet.europa.eu/schemas/mmr-article17/MMRArticle17Questionnaire.xsd
Output type EXCEL
Description MS Excel spreadsheet
XSL file article17-excel.xsl (Last modified: 26 Apr 2016 16:16 )
<?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" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xsl:output method="xml"/>
    <!--
        $Id$
        For http://dd.eionet.europa.eu/schemas/CO2-monitoring-cars_2014/cars-aggregated.xsd
    -->
    <xsl:variable name="labels" select="document('http://converters.eionet.europa.eu/xmlfile/article17-labels.xml')/labels"/>
    <!--<xsl:variable name="labels" select="document('../xml/article17-labels.xml')/labels"/>-->

    <xsl:variable name="codelists" select="document('http://converters.eionet.europa.eu/xmlfile/art17-codelists-en.xml')/Article17Codelists"/>
    <xsl:variable name="schema" select="document('http://dd.eionet.europa.eu/schemas/mmr-article17/MMRArticle17Questionnaire.xsd')/xs:schema"/>
    <xsl:variable name="heading" select="'MMRArticle17Questionnaire'" />

    <xsl:template match="/MMRArticle17Questionnaire">
        <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="row-height" style:family="table-cell">
                    <style:properties  style:row-height="2cm" />
                </style:style>
                <style:style style:name="string-cell" style:family="table-cell">
                    <style:properties fo:text-align="left"
                                      fo:font-size="10pt" style:column-width="5cm" />
                </style:style>
                <style:style style:name="long-string-cell" style:family="table-cell">
                    <style:properties fo:text-align="left"
                                      fo:font-size="10pt" style:column-width="10cm" />
                </style:style>
                <style:style style:name="number-cell" style:family="table-cell">
                    <style:properties fo:text-align="right"
                                      fo:font-size="10pt" style:column-width="5cm" />
                </style:style>
                <style:style style:name="long-number-cell" style:family="table-cell">
                    <style:properties fo:text-align="right"
                                      fo:font-size="10pt" style:column-width="10cm" />
                </style:style>
                <style:style style:name="total-number-cell" style:family="table-cell">
                    <style:properties fo:text-align="right" fo:font-weight="bold"
                                      fo:font-size="10pt" style:column-width="5cm" />
                </style:style>
                <style:style style:name="string-heading" style:family="table-cell">
                    <style:properties fo:text-align="left"
                                      fo:font-size="10pt" style:column-width="5cm" fo:font-weight="bold" style:row-height="2cm" />
                </style:style>
                <style:style style:name="long-string-heading" style:family="table-cell">
                    <style:properties fo:text-align="left"
                                      fo:font-size="10pt" style:column-width="10cm" fo:font-weight="bold" />
                </style:style>
                <style:style style:name="cell1" style:family="table-cell">
                    <style:properties fo:text-align="right"
                                      fo:font-size="10pt" style:column-width="5cm" />
                </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:column-width="5cm" />
                </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:column-width="5cm" style:row-height="2cm"/>
                </style:style>
                <style:style style:name="long-Heading2" style:family="table-cell">
                    <style:properties fo:text-align="left"
                                      fo:font-size="10pt" fo:font-weight="bold" style:column-width="10cm" style:row-height="2cm"/>
                </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>
                <style:style style:name="Heading4" style:family="table-cell">
                    <style:properties fo:text-align="right"
                                      fo:font-size="10pt" fo:font-weight="bold" style:column-width="10cm" />
                </style:style>
            </office:automatic-styles>
            <office:body>
                <xsl:for-each select="./*[local-name() = 'Table1' or local-name() = 'Table2' or local-name() = 'Table3' or local-name() = 'Table4' or local-name() = 'Table5']">
                    <xsl:if test="local-name(.)='Table1' or local-name(.)='Table2' or local-name(.)='Table3' or local-name(.)='Table4' or local-name(.)='Table5'">
                        <table:table>
                            <xsl:attribute name="table:name"><xsl:value-of select="local-name(.)" /></xsl:attribute>
                            <table:table-columns>
                                <xsl:choose>


                                    <xsl:when test="local-name(.)='Table1'">
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="long-string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="number"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="number"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                    </xsl:when>
                                    <xsl:when test="local-name(.)='Table2'">
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="long-string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="number"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                    </xsl:when>

                                    <xsl:when test="local-name(.)='Table3'">
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="long-string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                    </xsl:when>
                                    <xsl:when test="local-name(.)='Table4'">
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="long-string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="number"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="number"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="string-heading">
                                        </table:table-column>
                                        <table:table-column
                                                table:default-cell-value-type="string"
                                                table:default-cell-style-name="long-string-heading">
                                        </table:table-column>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <table:table-column
                                                table:default-cell-value-type="number"
                                                table:default-cell-style-name="string-heading">
                                            <xsl:choose>
                                                <!--         <xsl:when test="local-name(.)='Table1'">
                                                             <xsl:attribute name="table:number-columns-repeated"><xsl:value-of
                                                                     select="count($Table1Elements/element[@id != '1'])" /></xsl:attribute>

                                                         </xsl:when>
                                                        <xsl:when test="local-name(.)='Table2'">
                                                             <xsl:attribute name="table:number-columns-repeated"><xsl:value-of
                                                                     select="count($Table2Elements/element)" /></xsl:attribute>

                                                         </xsl:when>
                                                          <xsl:when test="local-name(.)='Table3'">
                                                             <xsl:attribute name="table:number-columns-repeated"><xsl:value-of
                                                                     select="count($Table3Elements/element)" /></xsl:attribute>

                                                         </xsl:when>
                                                         <xsl:when test="local-name(.)='Table4'">
                                                             <xsl:attribute name="table:number-columns-repeated"><xsl:value-of
                                                                     select="count($Table4Elements/element)" /></xsl:attribute>

                                                         </xsl:when>
                                                -->         <xsl:when test="local-name(.)='Table5'">
                                                <xsl:attribute name="table:number-columns-repeated"><xsl:value-of
                                                        select="count($Table5Elements/element)" /></xsl:attribute>

                                            </xsl:when>
                                                <xsl:otherwise></xsl:otherwise>
                                            </xsl:choose>

                                        </table:table-column>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </table:table-columns>

                            <table:table-rows>
                                <xsl:apply-templates select="." />
                            </table:table-rows>

                        </table:table>
                        <xsl:choose>
                            <xsl:when test="local-name(.)='Table1'">
                                <!--<table:table>-->
                                <!--<xsl:attribute name="table:name"><xsl:value-of select="'Table_1'" /></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($Table1Elements/element)" /></xsl:attribute>

                                    </table:table-column>
                                </table:table-columns>

                                 <table:table-rows>-->
                                <xsl:apply-templates select="MMRArticle17Questionnaire/Table1" />
                                <!-- </table:table-rows>
                             </table:table>-->
                            </xsl:when>
                            <xsl:when test="local-name(.)='Table2'">
                                <!-- <table:table>-->
                                <!--<xsl:attribute name="table:name"><xsl:value-of select="'Table_1'" /></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($Table2Elements/element)" /></xsl:attribute>
                                    </table:table-column>
                                </table:table-columns>

                                <table:table-rows>
                                -->
                                <xsl:apply-templates select="MMRArticle17Questionnaire/Table2" />
                                <!--</table:table-rows>
                            </table:table>-->
                            </xsl:when>
                            <xsl:when test="local-name(.)='Table3'">
                                <!--<table:table>-->
                                <!--<xsl:attribute name="table:name"><xsl:value-of select="'Table_1'" /></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($Table3Elements/element)" /></xsl:attribute>
                                    </table:table-column>
                                </table:table-columns>

                                <table:table-rows>-->
                                <xsl:apply-templates select="MMRArticle17Questionnaire/Table3" />
                                <!--</table:table-rows>
                            </table:table>-->
                            </xsl:when>
                            <xsl:when test="local-name(.)='Table4'">
                                <!--<table:table>-->
                                <!--<xsl:attribute name="table:name"><xsl:value-of select="'Table_1'" /></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($Table4Elements/element)" /></xsl:attribute>
                                    </table:table-column>
                                </table:table-columns>

                                <table:table-rows>-->
                                <xsl:apply-templates select="MMRArticle17Questionnaire/Table4" />
                                <!--</table:table-rows>
                            </table:table>-->
                            </xsl:when>
                            <xsl:when test="local-name(.)='Table5'">
                                <!--<table:table>-->
                                <!--<xsl:attribute name="table:name"><xsl:value-of select="'Table_1'" /></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($Table5Elements/element)" /></xsl:attribute>
                                    </table:table-column>
                                </table:table-columns>

                                <table:table-rows>-->
                                <xsl:apply-templates select="MMRArticle17Questionnaire/Table5" />
                                <!--</table:table-rows>
                            </table:table>-->SS
                            </xsl:when>
                            <xsl:otherwise></xsl:otherwise>
                        </xsl:choose>
                    </xsl:if>
                </xsl:for-each>
                <!--<xsl:call-template name="metadata-table" />-->
            </office:body>
        </office:document-content>
    </xsl:template>

    <xsl:template match="MMRArticle17Questionnaire/Table1">
        <xsl:if test="position()=1">
            <xsl:call-template name="header" />
        </xsl:if>
        <table:table-rows>
            <xsl:for-each select="./*">
                <xsl:choose>
                    <xsl:when test="local-name(.)= 'MethodologyOnCurrencyExchange'">
                        <table:table-row>
                            <table:table-cell table:style-name="long-string-cell">
                                <text:p>
                                    <xsl:call-template name="getLabel">
                                        <xsl:with-param name="labelName" select="'Table1-ExplanationOnMethodologyOfCurrencyExchange'"/>
                                    </xsl:call-template>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="cell1" table:number-columns-spanned="2">
                                <text:p>
                                    <xsl:value-of select="." />
                                </text:p>
                            </table:table-cell>
                        </table:table-row>
                    </xsl:when>
                    <xsl:when test="local-name(.)= 'MethodologyOnCommitmentAndDisbursement'">
                        <table:table-row>
                            <table:table-cell table:style-name="long-string-cell">
                                <text:p>
                                    <xsl:call-template name="getLabel">
                                        <xsl:with-param name="labelName" select="'Table1-ExplanationOnMethodologyOfCommitmentAndDisbursement'"/>
                                    </xsl:call-template>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="cell1" table:number-columns-spanned="2">
                                <text:p>
                                    <xsl:value-of select="." />
                                </text:p>
                            </table:table-cell>
                        </table:table-row>
                    </xsl:when>
                    <xsl:when test="local-name(.)= 'TotalAmountOfAuctioningRevenuesGeneratedAndUsed'">
                        <table:table-row>
                            <table:table-cell table:style-name="long-string-cell">
                                <text:p>
                                    <xsl:call-template name="getLabel">
                                        <xsl:with-param name="labelName" select="'Table1-TotalAuctioningAllowancesUsedAndGenerated'"/>
                                    </xsl:call-template>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./Euros" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./LocalCurrency" />
                                </text:p>
                            </table:table-cell>
                        </table:table-row>
                    </xsl:when>
                    <xsl:otherwise>
                        <table:table-row>
                            <table:table-cell table:style-name="long-string-cell">
                                <text:p>
                                    <xsl:call-template name="getLabel">
                                        <xsl:with-param name="labelName" select="concat('Table1-',local-name(.))"/>
                                    </xsl:call-template>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./Euros" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./LocalCurrency" />
                                </text:p>
                            </table:table-cell>
                        </table:table-row>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
        </table:table-rows>
    </xsl:template>

    <xsl:template match="MMRArticle17Questionnaire/Table2">
        <xsl:if test="position()=1">
            <xsl:call-template name="header" />
        </xsl:if>
        <table:table-rows>
            <xsl:for-each select="./*">
                <xsl:choose>
                    <xsl:when test="false()"></xsl:when>
                    <xsl:otherwise>
                        <table:table-row>
                            <table:table-cell table:style-name="long-string-cell">
                                <text:p>
                                    <xsl:value-of select="./PurposeForRevenues" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:value-of select="./ShortDescription" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./AmountForYear/Euros" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./AmountForYear/LocalCurrency" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:call-template name="getLabelInCodelist">
                                        <xsl:with-param name="labelName" select="./Status"/>
                                        <xsl:with-param name="schemaElementName" select="'CommittedDisbursedStatusType'"/>
                                    </xsl:call-template>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:choose>
                                        <xsl:when test="string(./RevenuesPursuantToArticle3d) = 'true'">
                                            <xsl:call-template name="getLabel">
                                                <xsl:with-param name="labelName" select="'yes'"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:when test="string(./RevenuesPursuantToArticle3d) = 'false'">
                                            <xsl:call-template name="getLabel">
                                                <xsl:with-param name="labelName" select="'no'"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise><xsl:value-of select="./RevenuesPursuantToArticle3d" /></xsl:otherwise>
                                    </xsl:choose>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:choose>
                                        <xsl:when test="string(./RevenuesPursuantToArticle10) = 'true'">
                                            <xsl:call-template name="getLabel">
                                                <xsl:with-param name="labelName" select="'yes'"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:when test="string(./RevenuesPursuantToArticle10) = 'false'">
                                            <xsl:call-template name="getLabel">
                                                <xsl:with-param name="labelName" select="'no'"/>
                                            </xsl:call-template>
                                        </xsl:when>
                                        <xsl:otherwise><xsl:value-of select="./RevenuesPursuantToArticle10" /></xsl:otherwise>
                                    </xsl:choose>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:for-each select="./*[local-name()='TypeOfUse']">
                                        <xsl:call-template name="getLabelInCodelist">
                                            <xsl:with-param name="labelName" select="."/>
                                            <xsl:with-param name="schemaElementName" select="'Table2TypeOfUsesType'"/>
                                        </xsl:call-template>
                                    </xsl:for-each>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:for-each select="./*[local-name()='FinancialInstrument']">
                                        <xsl:call-template name="getLabelInCodelist">
                                            <xsl:with-param name="labelName" select="."/>
                                            <xsl:with-param name="schemaElementName" select="'Table2FinancialInstrumentsType'"/>
                                        </xsl:call-template>
                                    </xsl:for-each>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:value-of select="./ImplementingAgency" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:value-of select="./AdditionalInfo" />
                                </text:p>
                            </table:table-cell>
                        </table:table-row>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
            <table:table-row>
                <table:table-cell table:style-name="long-Heading2">
                    <text:p>
                        <xsl:call-template name="getLabel">
                            <xsl:with-param name="labelName" select="'Table2-TotalAmountCommitted'"/>
                        </xsl:call-template>
                    </text:p>
                </table:table-cell>
                <table:table-cell table:style-name="cell1">
                    <text:p/>
                </table:table-cell>
                <table:table-cell table:style-name="total-number-cell">
                    <text:p>
                        <xsl:value-of select="sum(*[./Status = 'committed']/AmountForYear/Euros[number(.)=number(.)])" />
                    </text:p>
                </table:table-cell>
                <table:table-cell  table:style-name="total-number-cell">
                    <text:p>
                        <xsl:value-of select="sum(*[./Status = 'committed']/AmountForYear/LocalCurrency[number(.)=number(.)])" />
                    </text:p>
                </table:table-cell>
                <table:table-cell table:style-name="Heading2">
                    <text:p>
                        Committed
                    </text:p>
                </table:table-cell>
            </table:table-row>
            <table:table-row>
                <table:table-cell  table:style-name="long-Heading2">
                    <text:p>
                        <xsl:call-template name="getLabel">
                            <xsl:with-param name="labelName" select="'Table2-TotalAmountDisbursed'"/>
                        </xsl:call-template>
                    </text:p>
                </table:table-cell>
                <table:table-cell table:style-name="cell1">
                    <text:p/>
                </table:table-cell>
                <table:table-cell  table:style-name="total-number-cell">
                    <text:p>
                        <xsl:value-of select="sum(*[./Status = 'disbursed']/AmountForYear/Euros[number(.)=number(.)])" />
                    </text:p>
                </table:table-cell>
                <table:table-cell  table:style-name="total-number-cell">
                    <text:p>
                        <xsl:value-of select="sum(*[./Status = 'disbursed']/AmountForYear/LocalCurrency[number(.)=number(.)])" />
                    </text:p>
                </table:table-cell>
                <table:table-cell table:style-name="Heading2">
                    <text:p>
                        Disbursed
                    </text:p>
                </table:table-cell>
            </table:table-row>
        </table:table-rows>
    </xsl:template>

    <xsl:template match="MMRArticle17Questionnaire/Table3">
        <xsl:if test="position()=1">
            <xsl:call-template name="header" />
        </xsl:if>
        <table:table-rows>
            <xsl:for-each select="./*[local-name() = 'FixedQuestion']">
                <xsl:choose>
                    <xsl:when test="false()"></xsl:when>
                    <xsl:otherwise>
                        <table:table-row>
                            <table:table-cell table:style-name="long-string-cell">
                                <text:p>
                                    <xsl:call-template name="getLabelInCodelist">
                                        <xsl:with-param name="labelName" select="./TypeOfSupport"/>
                                        <xsl:with-param name="schemaElementName" select="'Table3TypeOfSupportsType'"/>
                                    </xsl:call-template>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./AmountCommitted/Euros" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./AmountCommitted/LocalCurrency" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./AmountDisbursed/Euros" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./AmountDisbursed/LocalCurrency" />
                                </text:p>
                            </table:table-cell>
                        </table:table-row>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
            <table:table-row>
                <table:table-cell table:style-name="long-string-cell">
                    <text:p>
                        <xsl:call-template name="getLabel">
                            <xsl:with-param name="labelName" select="'Table3-EventualExplanation'"/>
                        </xsl:call-template>
                    </text:p>
                </table:table-cell>
                <table:table-cell table:style-name="string-cell">
                    <text:p>
                        <xsl:value-of select="./EventualExplanation" />
                    </text:p>
                </table:table-cell>
            </table:table-row>
        </table:table-rows>
    </xsl:template>


    <xsl:template match="MMRArticle17Questionnaire/Table4">
        <xsl:if test="position()=1">
            <xsl:call-template name="header" />
        </xsl:if>
        <table:table-rows>
            <xsl:for-each select="./*">
                <xsl:for-each select="./*">
                    <xsl:choose>
                        <xsl:when test="false()"></xsl:when>
                        <xsl:otherwise>
                            <table:table-row>
                                <table:table-cell table:style-name="long-string-cell">
                                    <text:p>
                                        <xsl:call-template name="getLabelInCodelist">
                                            <xsl:with-param name="labelName" select="./UseOfRevenue"/>
                                            <xsl:with-param name="schemaElementName" select="'Table4UseOfRevenuesType'"/>
                                        </xsl:call-template>
                                    </text:p>
                                </table:table-cell>
                                <table:table-cell table:style-name="number-cell">
                                    <text:p>
                                        <xsl:value-of select="./AmountCommitted/Euros" />
                                    </text:p>
                                </table:table-cell>
                                <table:table-cell table:style-name="number-cell">
                                    <text:p>
                                        <xsl:value-of select="./AmountCommitted/LocalCurrency" />
                                    </text:p>
                                </table:table-cell>
                                <table:table-cell table:style-name="string-cell">
                                    <text:p>
                                        <xsl:call-template name="getLabelInCodelist">
                                            <xsl:with-param name="labelName" select="./Status"/>
                                            <xsl:with-param name="schemaElementName" select="'CommittedDisbursedStatusType'"/>
                                        </xsl:call-template>
                                    </text:p>
                                </table:table-cell>
                                <table:table-cell table:style-name="string-cell">
                                    <text:p>
                                        <xsl:call-template name="getLabelInCodelist">
                                            <xsl:with-param name="labelName" select="./TypeOfSupport"/>
                                            <xsl:with-param name="schemaElementName" select="'Table4TypeOfSupportsType'"/>
                                        </xsl:call-template>
                                    </text:p>
                                </table:table-cell>
                                <table:table-cell table:style-name="string-cell">
                                    <text:p>
                                        <xsl:for-each select="./*[local-name()='FinancialInstrument']">
                                            <xsl:call-template name="getLabelInCodelist">
                                                <xsl:with-param name="labelName" select="."/>
                                                <xsl:with-param name="schemaElementName" select="'Table4FinancialInstrumentsType'"/>
                                            </xsl:call-template>
                                        </xsl:for-each>
                                    </text:p>
                                </table:table-cell>
                                <table:table-cell table:style-name="string-cell">
                                    <text:p>
                                        <xsl:for-each select="./*[local-name()='Sector']">
                                            <xsl:call-template name="getLabelInCodelist">
                                                <xsl:with-param name="labelName" select="."/>
                                                <xsl:with-param name="schemaElementName" select="'Table4SectorsType'"/>
                                            </xsl:call-template>
                                        </xsl:for-each>
                                    </text:p>
                                </table:table-cell>
                                <table:table-cell table:style-name="string-cell">
                                    <text:p>
                                        <xsl:if test="./InformationNotAvailable = 'true'"><xsl:call-template name="getLabel"><xsl:with-param
                                                name="labelName" select="'InformationNotAvailable'"/></xsl:call-template></xsl:if>
                                    </text:p>
                                </table:table-cell>
                                <table:table-cell table:style-name="string-cell">
                                    <text:p>
                                        <xsl:value-of select="./AdditionalInfo" />
                                    </text:p>
                                </table:table-cell>
                            </table:table-row>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:for-each>
            </xsl:for-each>
        </table:table-rows>
    </xsl:template>


    <xsl:template match="MMRArticle17Questionnaire/Table5">
        <xsl:if test="position()=1">
            <xsl:call-template name="header" />
        </xsl:if>
        <table:table-rows>
            <xsl:for-each select="./*">
                <xsl:choose>
                    <xsl:when test="false()"></xsl:when>
                    <xsl:otherwise>
                        <table:table-row>
                            <table:table-cell table:style-name="long-string-cell">
                                <text:p>
                                    <xsl:value-of select="./Programme" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:value-of select="./Recipient" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./AmountCommitted/Euros" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="number-cell">
                                <text:p>
                                    <xsl:value-of select="./AmountCommitted/LocalCurrency" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:call-template name="getLabelInCodelist">
                                        <xsl:with-param name="labelName" select="./Status"/>
                                        <xsl:with-param name="schemaElementName" select="'CommittedDisbursedStatusType'"/>
                                    </xsl:call-template>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:call-template name="getLabelInCodelist">
                                        <xsl:with-param name="labelName" select="./TypeOfSupport"/>
                                        <xsl:with-param name="schemaElementName" select="'Table5TypeOfSupportsType'"/>
                                    </xsl:call-template>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:for-each select="./*[local-name()='Sector']">
                                        <xsl:call-template name="getLabelInCodelist">
                                            <xsl:with-param name="labelName" select="."/>
                                            <xsl:with-param name="schemaElementName" select="'Table4SectorsType'"/>
                                        </xsl:call-template>
                                    </xsl:for-each>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:for-each select="./*[local-name()='FinancialInstrument']">
                                        <xsl:call-template name="getLabelInCodelist">
                                            <xsl:with-param name="labelName" select="."/>
                                            <xsl:with-param name="schemaElementName" select="'Table5FinancialInstrumentsType'"/>
                                        </xsl:call-template>
                                    </xsl:for-each>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:value-of select="./ImplementingAgency" />
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:if test="./InformationNotAvailable = 'true'"><xsl:call-template name="getLabel"><xsl:with-param
                                            name="labelName" select="'InformationNotAvailable'"/></xsl:call-template></xsl:if>
                                </text:p>
                            </table:table-cell>
                            <table:table-cell table:style-name="string-cell">
                                <text:p>
                                    <xsl:value-of select="./AdditionalInfo" />
                                </text:p>
                            </table:table-cell>
                        </table:table-row>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
        </table:table-rows>
    </xsl:template>

    <!-- a named template, which creates the table header row -->
    <xsl:template name="header">
        <table:table-header-rows>

            <xsl:if test="local-name(.)= 'Table1'">
                <table:table-row table:default-cell-value-type="string"  >
                    <table:table-cell table:style-name="long-string-heading"  >
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell table:style-name="Heading2">
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'AmountForTheYear'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell table:number-columns-spanned="2" table:style-name="Heading2">
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'AmountForTheYear'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                </table:table-row>
            </xsl:if>


            <xsl:if test="local-name(.)= 'Table1'">

                <table:table-row table:default-cell-value-type="string"
                                 table:default-cell-style-name="Heading2" >
                    <xsl:for-each select="$Table1Elements/element">
                        <table:table-cell>
                            <text:p>
                                <xsl:call-template name="getLabel">
                                    <xsl:with-param name="labelName" select="@heading"/>
                                </xsl:call-template>
                            </text:p>
                        </table:table-cell>
                    </xsl:for-each>
                </table:table-row>
            </xsl:if>
            <xsl:if test="local-name(.)= 'Table2'">
                <table:table-row table:default-cell-value-type="string"
                                 table:default-cell-style-name="Heading2" >
                    <table:table-cell table:style-name="long-string-heading">
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell >
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell >
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table2-AmountForYear'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell >
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table2-AmountForYear'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell >
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell >
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table2-RevenuesPursuantTo'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell >
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table2-RevenuesPursuantTo'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell >
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell >
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell >
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell >
                        <text:p/>
                    </table:table-cell>
                </table:table-row>
                <table:table-row table:default-cell-value-type="string"
                                 table:default-cell-style-name="Heading2" >
                    <xsl:for-each select="$Table2Elements/element">
                        <table:table-cell >
                            <text:p>
                                <xsl:call-template name="getLabel">
                                    <xsl:with-param name="labelName" select="@heading"/>
                                </xsl:call-template>
                            </text:p>
                        </table:table-cell>
                    </xsl:for-each>
                </table:table-row>
            </xsl:if>
            <xsl:if test="local-name(.)= 'Table3'">
                <table:table-row table:default-cell-value-type="string"
                                 table:default-cell-style-name="Heading2" >
                    <table:table-cell table:style-name="long-string-heading">
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table3-Heading2'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table3-Heading2'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table3-Heading3'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table3-Heading3'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                </table:table-row>
                <table:table-row table:default-cell-value-type="string"
                                 table:default-cell-style-name="Heading2" >

                    <xsl:for-each select="$Table3Elements/element">
                        <table:table-cell>
                            <text:p>
                                <xsl:call-template name="getLabel">
                                    <xsl:with-param name="labelName" select="@heading"/>
                                </xsl:call-template>
                            </text:p>
                        </table:table-cell>
                    </xsl:for-each>
                </table:table-row>
            </xsl:if>
            <xsl:if test="local-name(.)= 'Table4'">
                <table:table-row table:default-cell-value-type="string"
                                 table:default-cell-style-name="Heading2" >
                    <table:table-cell table:style-name="long-string-heading">
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table4-Heading1'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table4-Heading1'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                </table:table-row>
                <table:table-row table:default-cell-value-type="string"
                                 table:default-cell-style-name="Heading2" >
                    <xsl:for-each select="$Table4Elements/element">
                        <table:table-cell>
                            <text:p>
                                <xsl:call-template name="getLabel">
                                    <xsl:with-param name="labelName" select="@heading"/>
                                </xsl:call-template>
                            </text:p>
                        </table:table-cell>
                    </xsl:for-each>
                </table:table-row>
            </xsl:if>
            <xsl:if test="local-name(.)= 'Table5'">
                <table:table-row table:default-cell-value-type="string"
                                 table:default-cell-style-name="Heading2" >
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table5-Heading1'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p>
                            <xsl:call-template name="getLabel">
                                <xsl:with-param name="labelName" select="'Table5-Heading1'"/>
                            </xsl:call-template>
                        </text:p>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                    <table:table-cell>
                        <text:p/>
                    </table:table-cell>
                </table:table-row>
                <table:table-row table:default-cell-value-type="string"
                                 table:default-cell-style-name="Heading2" >
                    <xsl:for-each select="$Table5Elements/element">
                        <table:table-cell>
                            <text:p>
                                <xsl:call-template name="getLabel">
                                    <xsl:with-param name="labelName" select="@heading"/>
                                </xsl:call-template>
                            </text:p>
                        </table:table-cell>
                    </xsl:for-each>
                </table:table-row>
            </xsl:if>

        </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="Heading3" />
                <table:table-column
                        table:default-cell-value-type="string"
                        table:default-cell-style-name="cell1" />
            </table:table-columns>

        </table:table>
    </xsl:template>

    <xsl:variable name="Table1Elements">
        <element id="1"/>
        <element id="2" name="Euros"  heading="ThousandEuros"/>
        <element id="3" name="LocalCurrency" heading="ThousandEurosInDomestic" />
    </xsl:variable>
    <xsl:variable name="Table2Elements">
        <element name="PurposeForRevenues" heading="Table2-PurposeForRevenues" />
        <element name="ShortDescription" heading="Table2-ShortDescription" />
        <element name="Euros" heading="ThousandEuros" />
        <element name="LocalCurrency" heading="ThousandEurosInDomestic" />
        <element name="Status" heading="Table2-Status" />
        <element name="RevenuesPursuantToArticle3d" heading="Table2-Article3D" />
        <element name="RevenuesPursuantToArticle10" heading="Table2-Article10" />
        <element name="TypeOfUse" heading="Table2-TypeOfUse" />
        <element name="FinancialInstrument" heading="Table2-FinancialInstrument" />
        <element name="ImplementingAgency" heading="Table2-ImplementingAgency" />
        <element name="AdditionalInfo" heading="AdditionalInfo" />
    </xsl:variable>
    <xsl:variable name="Table3Elements">
        <element name="TypeOfSupport" heading="Table3-Heading1" />
        <element name="Euros" heading="ThousandEuros" />
        <element name="LocalCurrency" heading="ThousandEurosInDomestic" />
        <element name="Euros" heading="ThousandEuros" />
        <element name="LocalCurrency" heading="ThousandEurosInDomestic" />
    </xsl:variable>
    <xsl:variable name="Table4Elements">
        <element/>
        <element name="Euros" heading="ThousandEuros" />
        <element name="LocalCurrency" heading="Table4-ThousandEurosInDomestic" />
        <element name="Status" heading="Table4-Status" />
        <element name="TypeOfSupport" heading="Table4-TypeOfSupport" />
        <element name="FinancialInstrument" heading="Table4-TypeOfFinancialInstrument" />
        <element name="Sector" heading="Table4-Sector" />
        <element name="InformationNotAvailable" heading="InformationNotAvailable" />
        <element name="AdditionalInfo" heading="AdditionalInfo" />
    </xsl:variable>
    <xsl:variable name="Table5Elements">
        <element name="Programme" heading="Table5-Programme" />
        <element name="Recipient" heading="Table5-Recipient" />
        <element name="Euros" heading="ThousandEuros" />
        <element name="LocalCurrency" heading="ThousandEurosInDomestic" />
        <element name="Status" heading="Table4-Status" />
        <element name="TypeOfSupport" heading="Table5-TypeOfSupport" />
        <element name="Sector" heading="Table4-Sector" />
        <element name="FinancialInstrument" heading="Table4-TypeOfFinancialInstrument" />
        <element name="ImplementingAgency" heading="Table5-ImplementingAgency" />
        <element name="InformationNotAvailable" heading="InformationNotAvailable" />
        <element name="AdditionalInfo" heading="AdditionalInfo" />
    </xsl:variable>


    <xsl:template name="getLabel" >
        <xsl:param name="labelName"/>
        <!--<xsl:param name="lang" select="'en'"/>-->
        <xsl:variable name="labelValue" select="$labels/*[local-name() = $labelName]"/>
        <xsl:choose>
            <xsl:when test="string-length($labelValue) &gt; 0">
                <xsl:choose>
                    <xsl:when test="contains($labelValue,'{{reportingYear}}')">
                        <xsl:value-of select="replace($labelValue,'\{\{reportingYear\}\}', string(../@year))"/>
                    </xsl:when>
                    <xsl:otherwise><xsl:value-of select="$labelValue"/></xsl:otherwise>
                </xsl:choose>

            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$labelName"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="getLabelInCodelist" >
        <xsl:param name="labelName"/>
        <xsl:param name="codlistName" select="''"/>
        <xsl:param name="schemaElementName" select="''"/>
        <!--<xsl:param name="lang" select="'en'"/>-->
        <xsl:choose>
            <xsl:when test="$schemaElementName = 'Table2FinancialInstrumentsType'">
                <xsl:variable name="labelValue" select="$schema/xs:simpleType[@name = $schemaElementName]//xs:enumeration[@value = $labelName]/xs:annotation/xs:documentation"/>
                <xsl:choose>
                    <xsl:when test="string-length($labelValue) &gt; 0"><xsl:value-of select="$labelValue"/>; </xsl:when>
                    <xsl:otherwise><xsl:value-of select="$labelName"/></xsl:otherwise>
                </xsl:choose>

            </xsl:when>
            <xsl:when test="$schemaElementName = 'Table4FinancialInstrumentsType'">
                <xsl:variable name="labelValue" select="$schema/xs:simpleType[@name = $schemaElementName]//xs:enumeration[@value = $labelName]/xs:annotation/xs:documentation" />
                <xsl:choose>
                    <xsl:when test="string-length($labelValue) &gt; 0"><xsl:value-of select="$labelValue"/>; </xsl:when>
                    <xsl:otherwise><xsl:value-of select="$labelName"/> </xsl:otherwise>
                </xsl:choose>

            </xsl:when>
            <xsl:when test="$schemaElementName = 'Table4SectorsType'">
                <xsl:variable name="labelValue" select="$schema/xs:simpleType[@name = $schemaElementName]//xs:enumeration[@value = $labelName]/xs:annotation/xs:documentation"/>
                <xsl:choose>
                    <xsl:when test="string-length($labelValue) &gt; 0"><xsl:value-of select="$labelValue"/>; </xsl:when>
                    <xsl:otherwise><xsl:value-of select="normalize-space($labelName)"/> </xsl:otherwise>
                </xsl:choose>

            </xsl:when>
            <xsl:when test="$schemaElementName = 'Table2TypeOfUsesType'">
                <xsl:variable name="labelValue" select="$schema/xs:simpleType[@name = $schemaElementName]//xs:enumeration[@value = $labelName]/xs:annotation/xs:documentation"/>
                <xsl:choose>
                    <xsl:when test="string-length($labelValue) &gt; 0"><xsl:value-of select="$labelValue"/>; </xsl:when>
                    <xsl:otherwise><xsl:value-of select="$labelName"/> </xsl:otherwise>
                </xsl:choose>

            </xsl:when>
            <xsl:when test="$schemaElementName = 'Table4UseOfRevenuesType'">
                <xsl:variable name="labelValue"  select="$schema/xs:simpleType[@name = $schemaElementName]//xs:enumeration[@value = $labelName]/xs:annotation/xs:documentation"/>
                <xsl:choose>
                    <xsl:when test="string-length($labelValue) &gt; 0"><xsl:value-of select="$labelValue"/></xsl:when>
                    <xsl:otherwise><xsl:call-template name="getLabel"><xsl:with-param name="labelName" select="'Table4-OtherMultilateralFunds'"/></xsl:call-template><xsl:value-of select="."/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
                <xsl:variable name="labelValue" select="$schema/xs:simpleType[@name = $schemaElementName]//xs:enumeration[@value = $labelName]/xs:annotation/xs:documentation"/>
                <xsl:choose>
                    <xsl:when test="string-length($labelValue[1]) &gt; 0">
                        <xsl:choose>
                            <xsl:when test="string-length(labelValue) &gt; 0"><xsl:value-of select="$labelValue"/></xsl:when>
                            <xsl:otherwise><xsl:value-of select="$labelValue"/></xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:otherwise><xsl:value-of select="$labelName"/></xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

</xsl:stylesheet>