
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
    xmlns:dd802="https://dd.eionet.europa.eu/namespace.jsp?ns_id=802" xmlns:dd853="https://dd.eionet.europa.eu/namespace.jsp?ns_id=853">
    <xsl:output method="xml"/>

    <xsl:template match="/">
<delivery>        <xsl:apply-templates select="dd802:FLAInvestments/dd802:Row"/>
</delivery>    </xsl:template>

    <xsl:template match="dd802:FLAInvestments/dd802:Row">
        <xsl:if test="position()=1">
            <xsl:call-template name="table-def"/>
<xsl:text disable-output-escaping="yes">&lt;data&gt;</xsl:text>        </xsl:if>

<row>
   <xsl:variable xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="row" select="."></xsl:variable>
   <xsl:for-each xmlns:xsl="http://www.w3.org/1999/XSL/Transform" select="$elementsMetadata/element">
      <xsl:variable name="elemIdentifier">
         <xsl:value-of select="identifier"></xsl:value-of>
      </xsl:variable><xsl:text disable-output-escaping="yes">&lt;</xsl:text><xsl:value-of select="$elemIdentifier"/><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
      <xsl:variable name="multiValueSeparator">
         <xsl:call-template name="getSeparator">
            <xsl:with-param name="element" select="$elemIdentifier"></xsl:with-param>
         </xsl:call-template>
      </xsl:variable>
      <xsl:choose>
         <xsl:when test="count($row/*[local-name()= $elemIdentifier])=0 or string-join($row/*[local-name()= $elemIdentifier ],'')=''"></xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="string-join($row/*[local-name()= $elemIdentifier ],$multiValueSeparator)"></xsl:value-of>
         </xsl:otherwise>
      </xsl:choose><xsl:text disable-output-escaping="yes">&lt;/</xsl:text><xsl:value-of select="$elemIdentifier"/><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
   </xsl:for-each>
</row>        <xsl:if test="position()=last()">
<xsl:text disable-output-escaping="yes">&lt;/data&gt;</xsl:text>        </xsl:if>
</xsl:template>

<xsl:template name="table-def">

<table><elem>
<name>flarepCode</name>
<type>string</type>
<length>16</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecCode</name>
<type>string</type>
<length>32</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecStartYear</name>
<type></type>
<length></length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecEndYear</name>
<type></type>
<length></length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecPeriod</name>
<type></type>
<length></length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecCapacity</name>
<type>integer</type>
<length>9</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecInvCol</name>
<type>decimal</type>
<length>10</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecInvTp</name>
<type>decimal</type>
<length>10</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecInvComments</name>
<type>string</type>
<length>4096</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecInvIAS</name>
<type>decimal</type>
<length>10</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecOpCosts</name>
<type>decimal</type>
<length>10</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecEUFunds</name>
<type>decimal</type>
<length>10</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecJobs</name>
<type>integer</type>
<length>9</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecLenghtCoCs</name>
<type>decimal</type>
<length>10</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecLenghtSaCs</name>
<type>decimal</type>
<length>10</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecLenghtStCs</name>
<type>decimal</type>
<length>10</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecNumbIAS</name>
<type>integer</type>
<length>9</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>soecPop</name>
<type>integer</type>
<length>9</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem></table></xsl:template>

<xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="getSeparator">
   <xsl:param name="element" select="''"></xsl:param>
   <xsl:value-of select="','"></xsl:value-of>
</xsl:template>
<xsl:variable xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="elementsMetadata">
   <element>
      <elementid>86591</elementid>
      <identifier>flarepCode</identifier>
      <parentNS>null</parentNS>
      <type>string</type>
      <length>16</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94346</elementid>
      <identifier>soecCode</identifier>
      <parentNS>853</parentNS>
      <type>string</type>
      <length>32</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94338</elementid>
      <identifier>soecStartYear</identifier>
      <parentNS>853</parentNS>
      <type></type>
      <length></length>
      <precision></precision>
   </element>
   <element>
      <elementid>94352</elementid>
      <identifier>soecEndYear</identifier>
      <parentNS>853</parentNS>
      <type></type>
      <length></length>
      <precision></precision>
   </element>
   <element>
      <elementid>94349</elementid>
      <identifier>soecPeriod</identifier>
      <parentNS>853</parentNS>
      <type></type>
      <length></length>
      <precision></precision>
   </element>
   <element>
      <elementid>94342</elementid>
      <identifier>soecCapacity</identifier>
      <parentNS>853</parentNS>
      <type>integer</type>
      <length>9</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94345</elementid>
      <identifier>soecInvCol</identifier>
      <parentNS>853</parentNS>
      <type>decimal</type>
      <length>10</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94379</elementid>
      <identifier>soecInvTp</identifier>
      <parentNS>853</parentNS>
      <type>decimal</type>
      <length>10</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94363</elementid>
      <identifier>soecInvComments</identifier>
      <parentNS>853</parentNS>
      <type>string</type>
      <length>4096</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94383</elementid>
      <identifier>soecInvIAS</identifier>
      <parentNS>853</parentNS>
      <type>decimal</type>
      <length>10</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94371</elementid>
      <identifier>soecOpCosts</identifier>
      <parentNS>853</parentNS>
      <type>decimal</type>
      <length>10</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94355</elementid>
      <identifier>soecEUFunds</identifier>
      <parentNS>853</parentNS>
      <type>decimal</type>
      <length>10</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94360</elementid>
      <identifier>soecJobs</identifier>
      <parentNS>853</parentNS>
      <type>integer</type>
      <length>9</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94368</elementid>
      <identifier>soecLenghtCoCs</identifier>
      <parentNS>853</parentNS>
      <type>decimal</type>
      <length>10</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94357</elementid>
      <identifier>soecLenghtSaCs</identifier>
      <parentNS>853</parentNS>
      <type>decimal</type>
      <length>10</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94356</elementid>
      <identifier>soecLenghtStCs</identifier>
      <parentNS>853</parentNS>
      <type>decimal</type>
      <length>10</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94364</elementid>
      <identifier>soecNumbIAS</identifier>
      <parentNS>853</parentNS>
      <type>integer</type>
      <length>9</length>
      <precision></precision>
   </element>
   <element>
      <elementid>94367</elementid>
      <identifier>soecPop</identifier>
      <parentNS>853</parentNS>
      <type>integer</type>
      <length>9</length>
      <precision></precision>
   </element>
</xsl:variable>
</xsl:stylesheet>
