<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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 mayf2yahu.xsl -->
		<xsl:value-of select="substring(translate('$Revision$', '$ ', ''), 10)"/>
	</xsl:variable>

	<xsl:template match="opdracht">
		<facilitor>
			<xsl:element name="melding">
				<xsl:attribute name="key">
					<xsl:value-of select="melding_key"/>/<xsl:value-of select="bedrijfopdr_volgnr"/>
				</xsl:attribute>
				<xsl:attribute name="type">insert</xsl:attribute>
				<datum>
					<xsl:value-of select="tracking/track[@code='ORDNEW']/datum/jaar"/>-<xsl:value-of select="tracking/track[@code='ORDNEW']/datum/maand"/>-<xsl:value-of select="tracking/track[@code='ORDNEW']/datum/dag"/>
					<xsl:text> </xsl:text>
					<xsl:value-of select="tracking/track[@code='ORDNEW']/datum/tijd"/>:00
				</datum>
				<melder>
					<xsl:value-of select="melding/voor/naam_full"/>
				</melder>
				<stdmelding>
					<xsl:choose>
						<!--Automatische deuren;klacht automatische deuren;113;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '113'">1</xsl:when>
						<!--Automatische deuren;wens automatische deuren;114;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '114'">3</xsl:when>
						<!--Automatische deuren;storing automatische deuren;115;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '115'">2</xsl:when>
						<!--BMC/BMI;klacht BMC/BMI;80;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '80'">4</xsl:when>
						<!--BMC/BMI;wens BMC/BMI;81;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '81'">6</xsl:when>
						<!--BMC/BMI;storing BMC/BMI;82;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '82'">5</xsl:when>
						<!--Bouwkundig;klacht bouwkundig;101;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '101'">7</xsl:when>
						<!--Bouwkundig;wens bouwkundig;102;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '102'">9</xsl:when>
						<!--Bouwkundig;storing bouwkundig;103;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '103'">8</xsl:when>
						<!--Brandbestrijding;klacht brandbestrijding;98;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '98'">10</xsl:when>
						<!--Brandbestrijding;wens brandbestrijding;99;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '99'">12</xsl:when>
						<!--Brandbestrijding;storing brandbestrijding;100;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '100'">11</xsl:when>
						<!--Constructieve delen;klacht constructieve delen;104;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '104'">13</xsl:when>
						<!--Constructieve delen;wens constructieve delen;105;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '105'">15</xsl:when>
						<!--Constructieve delen;storing constructieve delen;106;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '106'">14</xsl:when>
						<!--Dakonderhoud;klacht dakonderhoud;92;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '92'">16</xsl:when>
						<!--Dakonderhoud;wens dakonderhoud;93;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '93'">18</xsl:when>
						<!--Dakonderhoud;storing dakonderhoud;94;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '94'">17</xsl:when>
						<!--E- installaties;klacht E- installaties;68;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '68'">19</xsl:when>
						<!--E- installaties;wens E- installaties;69;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '69'">21</xsl:when>
						<!--E- installaties;storing E- installaties;70;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '70'">20</xsl:when>
						<!--Gevelreiniging;klacht gevel;110;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '110'">22</xsl:when>
						<!--Gevelreiniging;wens gevel;111;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '111'">24</xsl:when>
						<!--Gevelreiniging;storing gevel;112;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '112'">23</xsl:when>
						<!--Glasbewassing;klacht glasbewassing;107;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '107'">25</xsl:when>
						<!--Glasbewassing;wens glasbewassing;108;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '108'">27</xsl:when>
						<!--Glasbewassing;storing glasbewassing;109;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '109'">26</xsl:when>
						<!--Glazenwasinstallatie;klacht glazenwasinstallaties;77;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '77'">28</xsl:when>
						<!--Glazenwasinstallatie;wens glazenwasinstallaties;78;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '78'">30</xsl:when>
						<!--Glazenwasinstallatie;storing glazenwasinstallaties;79;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '79'">29</xsl:when>
						<!--Lift installaties;klacht lift installaties;74;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '74'">31</xsl:when>
						<!--Lift installaties;wens lift installaties;75;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '75'">33</xsl:when>
						<!--Lift installaties;storing lift installaties;76;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '76'">32</xsl:when>
						<!--Onderhoud terrein;klacht onderhoud terrein;83;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '83'">35</xsl:when>
						<!--Onderhoud terrein;wens onderhoud terrein;84;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '84'">37</xsl:when>
						<!--Onderhoud terrein;storing onderhoud terrein;85;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '85'">36</xsl:when>
						<!--Riolering;klacht leegmaken riolering;65;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '65'">38</xsl:when>
						<!--Riolering;wens leegmaken riolering;66;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '66'">40</xsl:when>
						<!--Riolering;storing leegmaken riolering;67;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '67'">39</xsl:when>
						<!--Schilderwerk;klacht schilderwerk;95;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '95'">41</xsl:when>
						<!--Schilderwerk;wens schilderwerk;96;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '96'">43</xsl:when>
						<!--Schilderwerk;storing schilderwerk;97;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '97'">42</xsl:when>
						<!--Schoonhouden dak;storing schoonhouden dak;61;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '61'">44</xsl:when>
						<!--Schoonhouden dak;klacht schoonhouden dak;116;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '116'">46</xsl:when>
						<!--Schoonhouden dak;wens schoonhouden dak;117;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '117'">45</xsl:when>
						<!--Schoonmaak;klacht schoonmaak;86;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '86'">47</xsl:when>
						<!--Schoonmaak;wens schoonmaak;87;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '87'">49</xsl:when>
						<!--Schoonmaak;storing schoonmaak;88;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '88'">48</xsl:when>
						<!--Vetvangputten;klacht leegmaken vetvangputten;62;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '62'">50</xsl:when>
						<!--Vetvangputten;wens leegmaken vetvangputten;63;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '63'">52</xsl:when>
						<!--Vetvangputten;storing leegmaken vetvangputten;64;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '64'">51</xsl:when>
						<!--Vuilafvoer;klacht vuilafvoer;89;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '89'">53</xsl:when>
						<!--Vuilafvoer;wens vuilafvoer;90;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '90'">55</xsl:when>
						<!--Vuilafvoer;storing vuilafvoer;91;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '91'">54</xsl:when>
						<!--W-installaties;klacht W- installaties;71;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '71'">56</xsl:when>
						<!--W-installaties;wens W- installaties;72;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '72'">58</xsl:when>
						<!--W-installaties;storing W- installaties;73;4;10;;;-->
						<xsl:when test="melding/stdmelding/key = '73'">57</xsl:when>
						<!--Melding;Zie omschrijving;1;4;10;;;-->
						<xsl:otherwise>34</xsl:otherwise>
					</xsl:choose>
				</stdmelding>
				<prioriteit>
					<xsl:value-of select="melding/spoed"/>
				</prioriteit>
				<locatiecode>
					<xsl:value-of select="melding/plaats/regio/district/locatie/code"/>
				</locatiecode>
				<gebouwcode>
					<xsl:value-of select="melding/plaats/regio/district/locatie/gebouw/code"/>
				</gebouwcode>
				<verdiepingcode>
					<xsl:value-of select="melding/plaats/regio/district/locatie/gebouw/verdieping/code"/>
				</verdiepingcode>
				<ruimtenr>
					<xsl:value-of select="melding/plaats/regio/district/locatie/gebouw/verdieping/ruimte/nr"/>
				</ruimtenr>
				<omschrijving>
Mayfield-opdracht: <xsl:value-of select="melding_key"/>/<xsl:value-of select="bedrijfopdr_volgnr"/>
Prioriteit: <xsl:choose><xsl:when test="melding/spoed=1">Kritiek</xsl:when><xsl:when test="melding/spoed=2">Hoog</xsl:when><xsl:when test="melding/spoed=3">Normaal</xsl:when><xsl:otherwise>Laag</xsl:otherwise></xsl:choose>
Einddatum: <xsl:value-of select="einddatum/datum"/>
<xsl:if test="kenmerk[@naam='Bijlage 1']!=''"><xsl:text>&#xD;&#xA;</xsl:text>Bijlage 1: <xsl:value-of select="kenmerk[@naam='Bijlage 1']"/></xsl:if>
<xsl:if test="kenmerk[@naam='Bijlage 2']!=''"><xsl:text>&#xD;&#xA;</xsl:text>Bijlage 2: <xsl:value-of select="kenmerk[@naam='Bijlage 2']"/></xsl:if>
<xsl:if test="kenmerk[@naam='Bijlage 3']!=''"><xsl:text>&#xD;&#xA;</xsl:text>Bijlage 3: <xsl:value-of select="kenmerk[@naam='Bijlage 3']"/></xsl:if>
Melder: <xsl:value-of select="melding/voor/naam_full"/>
Huurder: <xsl:value-of select="melding/voor/afdeling/omschrijving"/>
Telefoon: <xsl:choose><xsl:when test="melding/voor/mobiel!=''"><xsl:value-of select="melding/voor/mobiel"/></xsl:when><xsl:when test="melding/voor/telefoonnr!=''"><xsl:value-of select="melding/voor/telefoonnr"/></xsl:when><xsl:otherwise>-</xsl:otherwise></xsl:choose>
<xsl:text>&#xD;&#xA;&#xD;&#xA;</xsl:text><xsl:value-of select="omschrijving"/>
				</omschrijving>
			</xsl:element>
		</facilitor>

	</xsl:template>

	<xsl:template match="facilitor">
		<xsl:apply-templates select="opdracht"/>
	</xsl:template>

	<xsl:template match="/">
		<xsl:choose>
			<xsl:when test="$mode='getExtension'">
				<xsl:element name="format">
					<xsl:element name="extension">xml</xsl:element>
				</xsl:element>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="facilitor"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>
