<?xml version="1.0"?>
<!--
@author Last Changed:$Author: Chandrasekhar Yadla $
@version $Revision: 1 $
@date $Date: 2011-12-23  $
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://schema.infor.com/InforOAGIS/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="com.infor.tfs.mappings.extensions.XsltExt" xmlns:tfs="http://www.infor.com/tfs">
	<!---->
	<!-- imports -->
	<xsl:import href="includes/BaseDefinitions.xsl" xml:base="../"/>
	
	<!---->
	<!--****************************************************************************************************-->
	<!-- LoadSpecialDemandByItem -->
	<!--****************************************************************************************************-->
	<xsl:template name="LoadSpecialDemandByItem">
		<LoadSpecialDemandByItem xmlns="http://schema.infor.com/InforOAGIS/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.infor.com/InforOAGIS/2 http://schema.infor.com/2.5.0/InforOAGIS/BODs/Developer/LoadSpecialDemandByItem.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" releaseID="9.2" versionID="2.5.0">
			<!-- ApplicationArea, Sender, CreationDateTime, BODID -->
			<xsl:call-template name="ApplicationArea"/>
			<!---->
			<xsl:apply-templates select="*"/>
		</LoadSpecialDemandByItem>
		
	</xsl:template>
	
	
	
	<xsl:template name="SpecialDemandByItem">
		<!-- parameter -->
		<xsl:param name="plant"/>
		<xsl:param name="vehicleClass"/>
		<xsl:param name="partNumber"/>
		<xsl:param name="cummulative"/>
		<xsl:param name="startDate"/>
		<xsl:param name="sequenceNumber"/>
		<xsl:param name="typeOfDemand"/>
		<xsl:param name="usageCode"/>
		
		<xsl:param name="accountingEntityID"/>
		<xsl:param name="lid"/>

		
		<xsl:variable name="accountingEntityIDInt">
            <xsl:choose>
                <xsl:when test="$accountingEntityID != ''">
                    <xsl:value-of select="$accountingEntityID"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="'#AEID#'"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="lidString">
            <xsl:choose>
                <xsl:when test="$lid != ''">
                    <xsl:value-of select="$lid"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="'#lidString#'"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
					<xsl:element name="SpecialDemandHeader">
								<xsl:element name="DocumentID">
								<xsl:element name="ID">
								<xsl:attribute name="accountingEntity"><xsl:value-of select="$accountingEntityIDInt"/></xsl:attribute>
								<xsl:attribute name="lid"><xsl:value-of select="$lidString"/></xsl:attribute>
									 <xsl:value-of select="concat($plant,'_',$vehicleClass,'_',$partNumber,'_',$sequenceNumber)"/>
								</xsl:element>		
								</xsl:element>		
								<xsl:element name="CumulativeQuantity">
									 <xsl:value-of select="$cummulative"/>
								</xsl:element>			
								<xsl:element name="StartDate">
									 <xsl:value-of select="$startDate"/>
								</xsl:element>
								<xsl:element name="DemandType">
									 <xsl:value-of select="$typeOfDemand"/>
								</xsl:element>			
								<xsl:element name="usageCode">
									 <xsl:value-of select="$usageCode"/>
								</xsl:element>	
					</xsl:element>	
		</xsl:template>
	
				
									
	<xsl:template name="SpecialDemandLine">
	<xsl:param name="DemandQuantity"/>
			<!--<xsl:for-each select="tokenize($DemandQuantity,'\+')">
				<xsl:element name="SpecialDemandLine">
						<xsl:element name="DemandQuantity">
							<xsl:value-of select="." />
						</xsl:element>
				</xsl:element>
			</xsl:for-each>-->
			<xsl:element name="SpecialDemandLine">
						<xsl:element name="DemandQuantity">
							<xsl:value-of select="$DemandQuantity" />
						</xsl:element>
						</xsl:element>
	</xsl:template>
	
</xsl:stylesheet>
