<?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">
		<!-- ******************************************************************* -->
		<!-- *****FlexWhere-request: GetRes                                      -->
		<!-- ******************************************************************* -->
		<xsl:if test="@view='uwva_v_flexwhere_getres'">
			<xsl:variable name="sorted">
				<xsl:for-each select="//data_row">
					<xsl:sort select="LOCATIE_CODE"/>
					<xsl:sort select="GEBOUW_CODE"/>
					<xsl:sort select="VERDIEPING_CODE"/>
					<xsl:sort select="RUIMTE_NR"/>
					<xsl:copy-of select="."/>
				</xsl:for-each>
			</xsl:variable>

			<xsl:choose>
				<xsl:when test="$mode='Res'">
					<GetResResponse>
						<GetResResult>
							<reserveringen>
								<xsl:for-each select="msxml:node-set($sorted)/data_row">
									<reservering>
										<locatiecode><xsl:value-of select="LOCATIE_CODE"/></locatiecode>
										<gebouwcode><xsl:value-of select="GEBOUW_CODE"/></gebouwcode>
										<verdiepingcode><xsl:value-of select="VERDIEPING_CODE"/></verdiepingcode>
										<ruimtecode><xsl:value-of select="RUIMTE_NR"/></ruimtecode>
										<resid><xsl:value-of select="RES_NR"/></resid>
										<datum><xsl:value-of select="DATUM"/></datum>
										<van><xsl:value-of select="VAN"/></van>
										<tot><xsl:value-of select="TOT"/></tot>
									</reservering>
								</xsl:for-each>
							</reserveringen>
						</GetResResult>
					</GetResResponse>
				</xsl:when>
				<xsl:otherwise>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>

	<!-- SOAP envelope met de afgesproken 'payload' in response op FlexWhere-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 FlexWhere-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>
