<?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" 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="rapport">
		<!-- ******************************************************************* -->
		<!-- *****WtcWebsite-request: GetAv                                      -->
		<!-- ******************************************************************* -->
		<xsl:if test="@view='wibc_v_ww_getav'">
			<xsl:variable name="sorted">
				<xsl:for-each select="//data_row">
					<xsl:sort select="concat(substring (AV_DATE,7,4), substring (AV_DATE,4,2), substring (AV_DATE,1,2))"/>
					<xsl:sort select="ACTIVITY"/>
					<xsl:copy-of select="."/>
				</xsl:for-each>
			</xsl:variable>

			<xsl:choose>
				<xsl:when test="$mode='Av'">
					<GetAvResponse>
						<xsl:choose>
							<xsl:when test="count(msxml:node-set($sorted)/data_row) = 0">
								<yes_no>NEE</yes_no>
							</xsl:when>
							<xsl:when test="count(msxml:node-set($sorted)/data_row) = 1">
							  <xsl:choose>
								  <xsl:when test="msxml:node-set($sorted)/data_row/MAX_DUR &gt; 1">
									  <yes_no>JA</yes_no>
								  </xsl:when>
								  <xsl:otherwise>
									  <yes_no>NEE</yes_no>
								  </xsl:otherwise>
							  </xsl:choose>
							</xsl:when>
							<xsl:otherwise>
								<!--yes_no>NEE</yes_no-->
							</xsl:otherwise>
						</xsl:choose>
					</GetAvResponse>
				</xsl:when>
				<xsl:otherwise>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>

	<!-- SOAP envelope met de afgesproken 'payload' in response op WtcWebsite-request! -->
	<xsl:template match="facilitor">
		<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
			<soap:Body>
				<xsl:apply-templates select="rapport"/>
			</soap:Body>
		</soap:Envelope>
	</xsl:template>

	<!-- De afgesproken 'payload' in response op WtcWebsite-request (zonder envelope)! -->
	<!--xsl:template match="facilitor">
		<xsl:apply-templates select="rapport"/>
	</xsl:template-->

	<!-- Root -->
	<xsl:template match="/">
		<xsl:apply-templates select="facilitor"/>
	</xsl:template>
</xsl:stylesheet>
