
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
    xmlns:dd579="https://dd.eionet.europa.eu/namespace.jsp?ns_id=579" xmlns:dd580="https://dd.eionet.europa.eu/namespace.jsp?ns_id=580">
    <xsl:output method="xml"/>

    <xsl:template match="/">
<delivery>        <xsl:apply-templates select="dd579:DWD_MS/dd579:Row"/>
</delivery>    </xsl:template>

    <xsl:template match="dd579:DWD_MS/dd579: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>CountryCode</name>
<type></type>
<length></length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>DWD_Year</name>
<type>integer</type>
<length>4</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_TotalPopulation</name>
<type>integer</type>
<length>100</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_NumberWSZ</name>
<type></type>
<length></length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_TotaResidentlPopulation</name>
<type></type>
<length></length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_TotalVolume</name>
<type></type>
<length></length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Groundwater</name>
<type></type>
<length></length>
<precision>2</precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Surfacewater</name>
<type>decimal</type>
<length>3</length>
<precision>2</precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Inlandwater</name>
<type>decimal</type>
<length>3</length>
<precision>2</precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Coastalwater</name>
<type></type>
<length></length>
<precision>2</precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Bankfiltrationwater</name>
<type>decimal</type>
<length>3</length>
<precision>2</precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Rainwater</name>
<type>decimal</type>
<length>3</length>
<precision>2</precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Otherwater</name>
<type>decimal</type>
<length>3</length>
<precision>2</precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_ArtificialGrondwaterRecharge</name>
<type>decimal</type>
<length>3</length>
<precision>2</precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_WebsiteAddress</name>
<type>string</type>
<length>300</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_ResponsibleAuthority</name>
<type>string</type>
<length>300</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Name</name>
<type>string</type>
<length>300</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Address</name>
<type>string</type>
<length>300</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_City</name>
<type>string</type>
<length>300</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Telephone</name>
<type>string</type>
<length>300</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Fax</name>
<type>string</type>
<length>300</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_Email</name>
<type>string</type>
<length>300</length>
<precision></precision>
<multiValueDelim></multiValueDelim>
</elem><elem>
<name>MS_NationalSummaryComment</name>
<type>string</type>
<length>2000</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>67135</elementid>
      <identifier>CountryCode</identifier>
      <parentNS>null</parentNS>
      <type></type>
      <length></length>
      <precision></precision>
   </element>
   <element>
      <elementid>72846</elementid>
      <identifier>DWD_Year</identifier>
      <parentNS>null</parentNS>
      <type>integer</type>
      <length>4</length>
      <precision></precision>
   </element>
   <element>
      <elementid>72880</elementid>
      <identifier>MS_TotalPopulation</identifier>
      <parentNS>580</parentNS>
      <type>integer</type>
      <length>100</length>
      <precision></precision>
   </element>
   <element>
      <elementid>72908</elementid>
      <identifier>MS_NumberWSZ</identifier>
      <parentNS>580</parentNS>
      <type></type>
      <length></length>
      <precision></precision>
   </element>
   <element>
      <elementid>72976</elementid>
      <identifier>MS_TotaResidentlPopulation</identifier>
      <parentNS>580</parentNS>
      <type></type>
      <length></length>
      <precision></precision>
   </element>
   <element>
      <elementid>72933</elementid>
      <identifier>MS_TotalVolume</identifier>
      <parentNS>580</parentNS>
      <type></type>
      <length></length>
      <precision></precision>
   </element>
   <element>
      <elementid>72963</elementid>
      <identifier>MS_Groundwater</identifier>
      <parentNS>580</parentNS>
      <type></type>
      <length></length>
      <precision>2</precision>
   </element>
   <element>
      <elementid>72929</elementid>
      <identifier>MS_Surfacewater</identifier>
      <parentNS>580</parentNS>
      <type>decimal</type>
      <length>3</length>
      <precision>2</precision>
   </element>
   <element>
      <elementid>72888</elementid>
      <identifier>MS_Inlandwater</identifier>
      <parentNS>580</parentNS>
      <type>decimal</type>
      <length>3</length>
      <precision>2</precision>
   </element>
   <element>
      <elementid>72861</elementid>
      <identifier>MS_Coastalwater</identifier>
      <parentNS>580</parentNS>
      <type></type>
      <length></length>
      <precision>2</precision>
   </element>
   <element>
      <elementid>72909</elementid>
      <identifier>MS_Bankfiltrationwater</identifier>
      <parentNS>580</parentNS>
      <type>decimal</type>
      <length>3</length>
      <precision>2</precision>
   </element>
   <element>
      <elementid>72885</elementid>
      <identifier>MS_Rainwater</identifier>
      <parentNS>580</parentNS>
      <type>decimal</type>
      <length>3</length>
      <precision>2</precision>
   </element>
   <element>
      <elementid>72938</elementid>
      <identifier>MS_Otherwater</identifier>
      <parentNS>580</parentNS>
      <type>decimal</type>
      <length>3</length>
      <precision>2</precision>
   </element>
   <element>
      <elementid>72874</elementid>
      <identifier>MS_ArtificialGrondwaterRecharge</identifier>
      <parentNS>580</parentNS>
      <type>decimal</type>
      <length>3</length>
      <precision>2</precision>
   </element>
   <element>
      <elementid>72889</elementid>
      <identifier>MS_WebsiteAddress</identifier>
      <parentNS>580</parentNS>
      <type>string</type>
      <length>300</length>
      <precision></precision>
   </element>
   <element>
      <elementid>72900</elementid>
      <identifier>MS_ResponsibleAuthority</identifier>
      <parentNS>580</parentNS>
      <type>string</type>
      <length>300</length>
      <precision></precision>
   </element>
   <element>
      <elementid>72935</elementid>
      <identifier>MS_Name</identifier>
      <parentNS>580</parentNS>
      <type>string</type>
      <length>300</length>
      <precision></precision>
   </element>
   <element>
      <elementid>72962</elementid>
      <identifier>MS_Address</identifier>
      <parentNS>580</parentNS>
      <type>string</type>
      <length>300</length>
      <precision></precision>
   </element>
   <element>
      <elementid>72859</elementid>
      <identifier>MS_City</identifier>
      <parentNS>580</parentNS>
      <type>string</type>
      <length>300</length>
      <precision></precision>
   </element>
   <element>
      <elementid>72967</elementid>
      <identifier>MS_Telephone</identifier>
      <parentNS>580</parentNS>
      <type>string</type>
      <length>300</length>
      <precision></precision>
   </element>
   <element>
      <elementid>72913</elementid>
      <identifier>MS_Fax</identifier>
      <parentNS>580</parentNS>
      <type>string</type>
      <length>300</length>
      <precision></precision>
   </element>
   <element>
      <elementid>72875</elementid>
      <identifier>MS_Email</identifier>
      <parentNS>580</parentNS>
      <type>string</type>
      <length>300</length>
      <precision></precision>
   </element>
   <element>
      <elementid>72950</elementid>
      <identifier>MS_NationalSummaryComment</identifier>
      <parentNS>580</parentNS>
      <type>string</type>
      <length>2000</length>
      <precision></precision>
   </element>
</xsl:variable>
</xsl:stylesheet>
