<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" version="1.0">
	<xsl:output method="xml" indent="yes" encoding="utf-8"/>
	<xsl:decimal-format name="european" decimal-separator="." grouping-separator=","/>
	<xsl:param name="mode"/>
	<xsl:variable name="Rev">
		<!-- Revision van deze cust.xsl -->
		<xsl:value-of select="substring(translate('$Revision$', '$ ', ''), 10)"/>
	</xsl:variable>

	<xsl:template match="reservering">
		<!-- ******************************************************************* -->
		<!-- *****Response naar TIBCO (of Smart Signs) nav. insert/update/delete -->
		<!-- ******************************************************************* -->
		<fclt:facilitorresponse xmlns:fclt="http://facilitor.nl/reserveringen">
		<xsl:element name="fclt:reservering">
			<xsl:attribute name="key"><xsl:value-of select="resid"/></xsl:attribute>
			<xsl:attribute name="type">response</xsl:attribute>
				<fclt:returncode><xsl:value-of select="returncode"/></fclt:returncode>
				<fclt:returntekst><xsl:value-of select="returntekst"/></fclt:returntekst>
				<fclt:datum><xsl:value-of select="datum"/></fclt:datum>
				<fclt:resid><xsl:value-of select="resid"/></fclt:resid>
		</xsl:element>
		</fclt:facilitorresponse>
	</xsl:template>

	<xsl:template match="facilitor">
		<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
			<SOAP-ENV:Body>
				<xsl:apply-templates select="reservering"/>
			</SOAP-ENV:Body>
		</SOAP-ENV:Envelope>
	</xsl:template>

	<!-- Root -->
  <xsl:template match="*">
    <xsl:choose>
    	<!-- Zonder prefix, dan response -> toevoegen envelop, namespace + prefix! -->
      <xsl:when test="substring-before(name(),concat(':', local-name()))=''">
        <xsl:if test="local-name()='facilitor'"><xsl:apply-templates select="facilitor"/></xsl:if>
      </xsl:when>
    	<!-- Met prefix, dan insert/update/delete ontvangen -> verwijderen prefix! -->
      <xsl:otherwise>
        <!-- remove element prefix -->
        <xsl:element name="{local-name()}">
          <!-- process attributes -->
          <xsl:for-each select="@*">
            <!-- remove attribute prefix -->
            <xsl:attribute name="{local-name()}">
              <xsl:value-of select="."/>
            </xsl:attribute>
          </xsl:for-each>
          <xsl:apply-templates/>
        </xsl:element>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>
