View stylesheet

XML schema http://dd.eionet.europa.eu/v2/dataset/3463/schema-dst-3463.xsd
Output type XML
Description Removes optionals
XSL file article17--optionals.xsl (Last modified: 22 Jan 2020 11:34 )
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
    <xsl:strip-space elements="*"/>

    <xsl:variable name="flacontact" select="('flaconStreet', 'flaconZIP', 'flaconCity', 'flaconFax', 'flaconRemarks')" />
    <xsl:variable name="flaagglomerations" select="('flaggEUFundName', 'flaggEUFund', 'flaggComments', 'flaggExpLoad', 'flaggExpLoadColl', 'flaggExpLoadIAS',
     'flaggOtherFund', 'flaggOtherFundName', 'flaggLoan', 'flaggLoanName')" />
    <xsl:variable name="flaauwwtps" select="('flatpEUFundName', 'flatpEUFund', 'flatpComments', 'flatpExpLoadTruck', 'flatpOtherFund', 'flatpOtherFundName', 'flatpLoan', 'flatpLoanName')" />
    <xsl:variable name="flainvestments" select="('soecInvComments', 'soecInvIAS', 'soecOpCosts', 'soecEUFunds', 'soecJobs', 'soecLenghtCoCs', 'soecLenghtSaCs', 'soecLenghtStCs', 'soecNumbIAS', 'soecPop')" />

    <xsl:template match="node()|@*">
        <xsl:choose>
            <xsl:when test="./local-name() = ($flacontact, $flaagglomerations, $flaauwwtps, $flainvestments)">
                <!-- Remove empty optional elements -->
                <xsl:if test=". != ''">
                    <xsl:copy>
                        <xsl:apply-templates select="node()|@*"/>
                    </xsl:copy>
                </xsl:if>
            </xsl:when>
            <xsl:otherwise>
                <xsl:copy>
                    <xsl:apply-templates select="node()|@*"/>
                </xsl:copy>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>