<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt">
	<xsl:output method="xml" indent="yes" encoding="utf-8"/>

	<xsl:decimal-format name="european" decimal-separator="," grouping-separator="."/>

	<xsl:variable name="Rev">
		<!-- Revision van deze MaasStatusResponse.xsl -->
		<xsl:value-of select="substring(translate('$Revision$', '$ ', ''), 10)"/>
	</xsl:variable>

	<xsl:template name="strip_prefix">
	  <xsl:param name="in"/>
	  <xsl:choose>
	    <xsl:when test="translate(substring($in,1,1), '01234567890', '')">
	      <xsl:call-template name="strip_prefix"><xsl:with-param name="in" select="substring($in, 2)"/></xsl:call-template>
	    </xsl:when>
	    <xsl:otherwise>
	      <xsl:value-of select="$in"/>
	    </xsl:otherwise>
	  </xsl:choose>
	</xsl:template>

	<xsl:template match="Service_Call_Status">
		<facilitor>
		   <xsl:if test="Customer_Call_Number != '' and Customer_Call_Number != 'Klant'">
			<xsl:element name="opdracht">
				<xsl:attribute name="key">
				  <xsl:call-template name="strip_prefix">
						<xsl:with-param name="in" select="Customer_Call_Number"/>
					</xsl:call-template>
				</xsl:attribute>
				<xsl:attribute name="type">update</xsl:attribute>
				<xsl:choose>
					<xsl:when test="Maas_Status_Code = 1 "><status>ORDACP</status></xsl:when>
					<xsl:when test="Maas_Status_Code = 2 "><status>ORDAFM</status></xsl:when>
					<xsl:when test="Maas_Status_Code = 4 "><status>ORDCAN</status></xsl:when>
					<xsl:otherwise>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:if test="Maas_Status_Date and Maas_Status_Date != '00000000'">
					<mut_datum>
						<xsl:value-of select="concat(substring(Maas_Status_Date,1,4), '-',
						                             substring(Maas_Status_Date,5,2), '-',
																				 substring(Maas_Status_Date,7,2), ' ',
																				 substring(Maas_Status_Time,1,2), ':',
																				 substring(Maas_Status_Time,3,2), ':',
																				 substring(Maas_Status_Time,3,2))"/>

					</mut_datum>
				</xsl:if>
				<opmerking>
					<xsl:value-of select="Maas_Status_Description"/> <xsl:if test="Maas_Remark">, <xsl:value-of select="Maas_Remark"/></xsl:if>
				</opmerking>
			</xsl:element>
			</xsl:if>
		</facilitor>
	</xsl:template>

	<xsl:template match="MAAS_XML">
		<xsl:apply-templates select="List_Service_Call_Status/Service_Call_Status"/>
	</xsl:template>

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