View stylesheet

XML schema http://dd.eionet.europa.eu/schemas/IEDAnnexIIModule1/module1.xsd
Output type EXCEL
Description MS Excel
XSL file IEDAnnexIIModule1-excel.xsl (Last modified: 08 Nov 2018 19:45 )
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="2.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"
                xmlns:skos="http://www.w3.org/2004/02/skos/core#"
                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <xsl:output method="xml"/>

    <xsl:variable name="AnnexIHeadingCodeURL"
        select="document('http://dd.eionet.europa.eu/vocabulary/IEDAnnexIIModule1/AnnexIHeadingCode/rdf')"/>

    <!-- <xsl:variable name="labelsLanguage" select="IEDModule1/@xml:lang"/> -->

    <!-- <xsl:variable name="labels" select="document('http://converterstest.eionet.europa.eu/xmlfile/IEDAnnexIIModule1-labels-en.xml')/labels"/> -->

    <xsl:variable name="schema"
                  select="document('http://dd.eionet.europa.eu/schemas/IEDAnnexIIModule1/module1.xsd')/xs:schema"/>
    <xsl:variable name="labelsLanguage" select="IEDModule1/@xml:lang"/>
    <xsl:variable name="xmlPath" select="'https://converterstest.eionet.europa.eu/xmlfile'"/>
    <xsl:variable name="labelsUrl">
        <xsl:choose>
            <xsl:when test="doc-available(concat($xmlPath, 'IEDAnnexIIModule1-labels-', $labelsLanguage ,'.xml'))">
                <xsl:value-of select="concat($xmlPath, 'IEDAnnexIIModule1-labels-', $labelsLanguage ,'.xml')"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="concat($xmlPath, '/IEDAnnexIIModule1-labels-en.xml')"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="labels" select="document($labelsUrl)/labels"/>

    
    <xsl:template name="getLabel">
        <xsl:param name="labelName"/>
        <xsl:variable name="labelValue" select="normalize-space($labels/*[local-name() = $labelName])"/>
        <xsl:choose>
            <xsl:when test="string-length($labelValue) &gt; 0">
                <xsl:value-of disable-output-escaping="yes" select="$labelValue"/>
            </xsl:when>
            <xsl:otherwise>- <xsl:value-of disable-output-escaping="yes" select="$labelName"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <xsl:template name="getYesNoValue">
        <xsl:param name="elem"/>
        <xsl:param name="codelistElement" select="''"/>
        <xsl:variable name="elemValue">
            <xsl:choose>
                <xsl:when test="$elem/text()='true'">Yes</xsl:when>
                <xsl:when test="$elem/text()='false'">No</xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$elem"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:value-of select="$elemValue"/>
    </xsl:template>

    <xsl:template name="getCDLValue">
        <xsl:param name="elem"/>
        <xsl:param name="codelistElement" select="''"/>
        <xsl:variable name="codeValue"
            select="$AnnexIHeadingCodeURL/rdf:RDF/skos:Concept/skos:notation[text()= $elem/text()]/../skos:prefLabel/text()"/>
        <xsl:choose>
            <xsl:when test="codeValue = ''">
                <xsl:value-of disable-output-escaping="yes" select="$elem"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of disable-output-escaping="yes" select="$codeValue"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="/IEDModule1">
                <!-- <xsl:apply-templates/> -->
        <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="15cm" />
                </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="Heading" style:family="table-cell">
                    <style:properties fo:text-align="center"
                                      fo:font-size="10pt" fo:font-weight="bold" style:column-width="3cm" style:row-height="2cm"/>
                </style:style>
                <style:style style:name="Heading2" style:family="table-cell">
                    <style:properties fo:text-align="left"
                                      fo:font-size="14pt" fo:font-weight="bold" style:column-width="10cm" 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="left"
                                      fo:font-size="12pt" fo:font-weight="normal" 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>
                <table:table>
                    <xsl:attribute name="table:name">
                        <xsl:call-template name="getLabel">
                            <xsl:with-param name="labelName" select="'implementationChanges'"/>
                        </xsl:call-template>
                    </xsl:attribute>
                        <table:table-columns>
                            <table:table-column table:default-cell-value-type="string" table:default-cell-style-name="long-string-heading">
                                <xsl:call-template name="getLabel">
                                    <xsl:with-param name="labelName" select="'question1_1'"/>
                                </xsl:call-template>
                            </table:table-column>
                            <table:table-column table:default-cell-value-type="string" table:default-cell-style-name="long-string-heading">
                                <xsl:call-template name="getLabel">
                                    <xsl:with-param name="labelName" select="'question1_1_description'"/>
                                </xsl:call-template>
                            </table:table-column>
                        </table:table-columns>
                        <table:table-rows>
                            <table:table-row table:default-cell-value-type="string"  >
                                <table:table-cell table:style-name="Heading2">
                                    <text:p>
                                        <xsl:call-template name="getLabel">
                                            <xsl:with-param name="labelName" select="'question1'"/>
                                        </xsl:call-template>
                                    </text:p>
                                </table:table-cell>
                                <table:table-cell  table:style-name="Heading3">
                                    <text:p>
                                        <xsl:call-template name="getYesNoValue">
                                            <xsl:with-param name="elem" select="./ImplementationChanges/q_1_changesMade"/>
                                        </xsl:call-template>
                                    </text:p>
                                </table:table-cell>
                            </table:table-row>
                            <xsl:if test="./ImplementationChanges/q_1_changesMade = true()">
                            <table:table-row table:default-cell-value-type="string"  >
                                <table:table-cell table:style-name="Heading2">
                                    <text:p>
                                        <xsl:call-template name="getLabel">
                                    <xsl:with-param name="labelName" select="'question1_1'"/>
                                </xsl:call-template>
                                    </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="'question1_1_description'"/>
                                        </xsl:call-template>
                                    </text:p>
                                </table:table-cell>
                            </table:table-row>
                            <xsl:for-each select="./ImplementationChanges/ReasonsChanges">
                                <table:table-row table:default-cell-value-type="string"  >
                                    <table:table-cell table:style-name="Heading3">
                                        <text:p>
                                            <xsl:call-template name="getCDLValue">
                                                <xsl:with-param name="elem" select="./Headings/q_1_1_heading"/>
                                                <xsl:with-param name="codelistElement" select="'AnnexIHeadingCode'"/>
                                            </xsl:call-template>
                                        </text:p>
                                    </table:table-cell>
                                    <table:table-cell  table:style-name="Heading3">
                                        <text:p>
                                            <xsl:value-of select="q_1_1_description"/>
                                        </text:p>
                                    </table:table-cell>
                                </table:table-row>
                            </xsl:for-each>
                        </xsl:if>
                        </table:table-rows>
                </table:table>
                <table:table>
                    <xsl:attribute name="table:name">
                        <xsl:call-template name="getLabel">
                            <xsl:with-param name="labelName" select="'implementationDifficulties'"/>
                        </xsl:call-template>
                    </xsl:attribute>
                    
                        <table:table-columns>
                            <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="long-string-heading">

                            </table:table-column>
                        </table:table-columns>
                        <table:table-rows>
                            <table:table-row table:default-cell-value-type="string"  >
                                <table:table-cell table:style-name="Heading2">
                                    <text:p>
                                        <xsl:call-template name="getLabel">
                                            <xsl:with-param name="labelName" select="'questions1_2'"/>
                                        </xsl:call-template>
                                    </text:p>
                                </table:table-cell>
                                <table:table-cell  table:style-name="Heading3">
                                    <text:p>
                                        <xsl:call-template name="getYesNoValue">
                                            <xsl:with-param name="elem" select="./ImplementationDifficulties/q_2_1_difficultiesEncountered"/>
                                        </xsl:call-template>
                                    </text:p>
                                </table:table-cell>
                            </table:table-row>
                            <xsl:if test="./ImplementationDifficulties/q_2_1_difficultiesEncountered = true()">
                            <table:table-row table:default-cell-value-type="string"  >
                                <table:table-cell table:style-name="Heading2">
                                    <text:p>
                                        <xsl:call-template name="getLabel">
                                            <xsl:with-param name="labelName" select="'questions1_2_1_table_1'"/>
                                        </xsl:call-template>
                                    </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="'questions1_2_1_table_2'"/>
                                        </xsl:call-template>
                                    </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="'questions1_2_1_table_3'"/>
                                        </xsl:call-template>
                                    </text:p>
                                </table:table-cell>
                            </table:table-row>
                            <xsl:for-each select="./ImplementationDifficulties/Difficulty">
                                <table:table-row table:default-cell-value-type="string"  >
                                    <table:table-cell table:style-name="Heading3">
                                        <text:p>
                                            <xsl:value-of select="./q_2_2_relevantArticle"/>
                                        </text:p>
                                    </table:table-cell>
                                    <table:table-cell  table:style-name="Heading3">
                                        <text:p>
                                            <xsl:value-of select="./q_2_2_description"/>
                                        </text:p>
                                    </table:table-cell>
                                    <table:table-cell  table:style-name="Heading3">
                                        <text:p>
                                            <xsl:value-of select="./q_2_2_reasons"/>
                                        </text:p>
                                    </table:table-cell>
                                </table:table-row>
                            </xsl:for-each>
                            </xsl:if>
                        </table:table-rows>
                </table:table>
                <xsl:apply-templates/>
            </office:body>
        </office:document-content>
    </xsl:template>
</xsl:stylesheet>