<?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:param name="mode"/>

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

	<xsl:template name="linebreaks">
    <xsl:param name="string"/>
    <xsl:choose>
      <xsl:when test="contains($string, '&#xA;')">
        <xsl:value-of select="substring-before($string, '&#xA;')"/>
		<xsl:text> - </xsl:text>
        <xsl:call-template name="linebreaks">
          <xsl:with-param name="string" select="substring-after($string, '&#xA;')"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$string"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

	<xsl:template match="opdracht">
		<xsl:element name="MAAS_XML">
			<xsl:element name="List_Service_Calls">
				<xsl:element name="Service_Call">
					<xsl:element name="Customer_Call_Number">
						<xsl:value-of select="melding/discipline/srtdiscipline/prefix"/>
						<xsl:value-of select="melding/key"/>/<xsl:value-of select="bedrijfopdr_volgnr"/></xsl:element>
					<xsl:element name="Customer_Call_Start_Date">
						<xsl:value-of select="melding/gemeld/jaar"/>
						<xsl:value-of select="melding/gemeld/maand"/>
						<xsl:value-of select="melding/gemeld/dag"/>
					</xsl:element>
					<xsl:element name="Customer_Call_Start_Time">
						<xsl:value-of select="concat(concat(substring-before(melding/gemeld/tijd,':'),substring-after(melding/gemeld/tijd,':')),'00')"/>
					</xsl:element>
					<xsl:element name="Customer_Requestor_Name">
						<xsl:value-of select="substring(melding/voor/naam_full,1,40)"/>
					</xsl:element>
					<xsl:element name="Customer_Requestor_Telephone_Number">
						<xsl:value-of select="melding/voor/telefoonnr"/>
					</xsl:element>
					<xsl:element name="Customer_Coordinator_Name">
						<xsl:value-of select="substring(backoffice_contact/naam_full,1,40)"/>
					</xsl:element>
					<xsl:element name="Customer_Coordinator_Telephone_Number">
						<xsl:value-of select="backoffice_contact/telefoonnr"/>
					</xsl:element>
					<xsl:element name="Customer_Coordinator_Email_Address">
						<xsl:value-of select="substring(backoffice_contact/email,1,60)"/>
					</xsl:element>
					<xsl:element name="Customer_Site_Name">
						<xsl:value-of select="melding/plaats/regio/district/locatie/omschrijving"/>
					</xsl:element>
					<xsl:element name="Customer_Site_Street">
						<xsl:value-of select="melding/plaats/regio/district/locatie/adres"/>
					</xsl:element>
					<xsl:element name="Customer_Site_Postal_Code">
						<xsl:value-of select="melding/plaats/regio/district/locatie/postcode"/>
					</xsl:element>
					<xsl:element name="Customer_Site_City">
						<xsl:value-of select="melding/plaats/regio/district/locatie/plaats"/>
					</xsl:element>
					<xsl:if test="count(melding/deel)&gt;0">
						<xsl:element name="Customer_Installation_Code">
							<xsl:for-each select="melding/deel">
								<xsl:sort select="omschrijving"/>
								<xsl:if test="position()=1">
									<xsl:value-of select="omschrijving"/>
								</xsl:if>
							</xsl:for-each>
						</xsl:element>
					</xsl:if>
					<xsl:element name="Customer_Installation_Description">
						<xsl:value-of select="melding/plaats/plaatsaanduiding"/>
					</xsl:element>
					<xsl:element name="Customer_Call_Description">
						<xsl:call-template name="linebreaks">
        						<xsl:with-param name="string" select="omschrijving"/>
      					</xsl:call-template>
					</xsl:element>
					<xsl:element name="Maas_Installation_Code">
						<xsl:for-each select="melding/deel">
							<xsl:sort select="omschrijving"/>
							<xsl:if test="position()=1">
							<xsl:value-of select="kenmerk[@naam='Machine number'] "/>
							</xsl:if>
						</xsl:for-each>
					</xsl:element>
				</xsl:element>
			</xsl:element>
		</xsl:element>
	</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><!-- Stylus Studio meta-information - (c) 2004-2006. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="..\..\..\reportsCache\LOGIopdracht4921&#x2D;.xml" htmlbaseurl="" outputurl="" processortype="internal" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->