<?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="rapport">
		<!-- ******************************************************************* -->
		<!-- ***** Smart Signs: GetReserveringen ******************************* -->
		<!-- ******************************************************************* -->
		<xsl:variable name="view">
		   <xsl:value-of select="@view"/>
		</xsl:variable>
		<xsl:if test="@view='res_v_api_reserveringen' or @view='pnbr_v_api_reserveringen'">
			<xsl:variable name="sorted">
				<xsl:for-each select="GetReserveringenResponse/reservering">
					<xsl:sort select="VAN"/>
					<xsl:sort select="LOCATIECODE"/>
					<xsl:sort select="GEBOUWCODE"/>
					<xsl:sort select="VERDIEPINGCODE"/>
					<xsl:sort select="RUIMTECODE"/>
					<xsl:sort select="KEY"/>
					<xsl:if test="RUIMTENAAM!=''">
					  <xsl:copy-of select="."/>
					</xsl:if>
				</xsl:for-each>
			</xsl:variable>

			<xsl:variable name="dagstaat">
				<xsl:for-each select="GetReserveringenResponse/reservering">
					<xsl:sort select="KEY"/>
					<xsl:if test="K_NAAM = 'Zichtbaar op dagstaat'">
					  <xsl:copy-of select="."/>
					</xsl:if>
				</xsl:for-each>
			</xsl:variable>

			<xsl:choose>
				<xsl:when test="$mode='Reserveringen'">
					<GetReserveringenResponse>
						<xsl:for-each select="msxml:node-set($sorted)/reservering">
							<xsl:variable name="key"><xsl:value-of select="KEY"/></xsl:variable>
							<xsl:element name="reservering">
							<xsl:attribute name="key"><xsl:value-of select="KEY"/></xsl:attribute>
								<locatiecode><xsl:value-of select="LOCATIECODE"/></locatiecode>
								<gebouwcode><xsl:value-of select="GEBOUWCODE"/></gebouwcode>
								<verdiepingcode><xsl:value-of select="VERDIEPINGCODE"/></verdiepingcode>
								<ruimtecode><xsl:value-of select="RUIMTECODE"/></ruimtecode>
								<ruimtenaam><xsl:value-of select="RUIMTENAAM"/></ruimtenaam>
								<algruimtekey><xsl:value-of select="ALGRUIMTEKEY"/></algruimtekey>
								<resruimtekey><xsl:value-of select="RESRUIMTEKEY"/></resruimtekey>
								<algruimtenr><xsl:value-of select="ALGRUIMTENR"/></algruimtenr>
								<resid><xsl:value-of select="RESID"/></resid>
								<van><xsl:value-of select="VAN"/></van>
								<tot><xsl:value-of select="TOT"/></tot>
								<fo_status><xsl:value-of select="FO_STATUS"/></fo_status>
								<omschrijving><xsl:value-of select="OMSCHRIJVING"/></omschrijving>
								<contact><xsl:value-of select="CONTACT"/></contact>
								<host><xsl:value-of select="HOST"/></host>
								<xsl:if test="$view='res_v_api_reserveringen'">
								   <dagstaat> 
									   <xsl:for-each select="msxml:node-set($dagstaat)/reservering[KEY=$key]">
									   <xsl:value-of select="K_WAARDE"/></xsl:for-each>
								   </dagstaat>
								</xsl:if>
								<xsl:if test="$view='pnbr_v_api_reserveringen'">
								   <dagstaat> 
									   <xsl:value-of select="DAGSTAAT"/>
								   </dagstaat>
								</xsl:if>
							</xsl:element>
						</xsl:for-each>
					</GetReserveringenResponse>
				</xsl:when>
				<xsl:otherwise>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>

	<!-- SOAP envelope met de afgesproken 'payload' in response op request! -->
	<xsl:template match="facilitor">
		<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
			<soap:Body>
				<xsl:apply-templates select="rapport"/>
			</soap:Body>
		</soap:Envelope>
	</xsl:template>

	<!-- De afgesproken 'payload' in response op 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>
<!-- Stylesheet edited using Stylus Studio - (c) 2004-2007. Progress Software Corporation. All rights reserved. --><!-- Stylesheet edited using Stylus Studio - (c) 2004-2007. Progress Software Corporation. All rights reserved. -->