<?xml version="1.0"?>
<!--
@author Last Changed:$Author: fbrodersen $
@version $Revision: 7898 $
@date $Date: 2011-04-28 14:52:08 +0200 (Do, 28 Apr 2011) $
-->
<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">
	<!---->
	<!-- template to insert -->
	<xsl:template name="TimePeriod">
		<!---->
		<!-- parameter -->
		<xsl:param name="name"/>
		<xsl:param name="fromDate"/>
		<xsl:param name="fromTime"/>
		<xsl:param name="toDate"/>
		<xsl:param name="toTime"/>
		<xsl:param name="duration"/>
		<!---->
		<!-- set Name -->
		<xsl:variable name="nameInt">
			<xsl:choose>
				<xsl:when test="$name != ''">
					<xsl:value-of select="$name"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="'TimePeriod'"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<!---->
		<!-- TimePeriod -->
		<xsl:if test="$fromDate !='' or $toDate !='' or $duration !=''">
			<xsl:element name="{$nameInt}">
				<!---->
				<!-- StartDateTime -->
				<xsl:if test="$fromDate !=''">
					<xsl:call-template name="DateTime">
						<xsl:with-param name="name">
							<xsl:value-of select="'StartDateTime'"/>
						</xsl:with-param>
						<xsl:with-param name="date">
							<xsl:value-of select="$fromDate"/>
						</xsl:with-param>
						<xsl:with-param name="time">
							<xsl:value-of select="$fromTime"/>
						</xsl:with-param>
					</xsl:call-template>
				</xsl:if>
				<!---->
				<!-- EndDateTime -->
				<xsl:if test="$toDate !='' and $toDate !='000000'">
					<xsl:if test="string-length($toDate) = 8">
					<xsl:call-template name="DateTime">
						<xsl:with-param name="name">
							<xsl:value-of select="'EndDateTime'"/>
						</xsl:with-param>
						<xsl:with-param name="date">
							<xsl:value-of select="$toDate"/>
						</xsl:with-param>
						<xsl:with-param name="time">
							<xsl:value-of select="$toTime"/>
						</xsl:with-param>
					</xsl:call-template>
				</xsl:if>				
					<xsl:if test="string-length($toDate) = 6">
					<xsl:call-template name="DateTime">
						<xsl:with-param name="name">
							<xsl:value-of select="'EndDateTime'"/>
						</xsl:with-param>
						<xsl:with-param name="date">
							<xsl:value-of select="concat('20',$toDate)"/>
						</xsl:with-param>
						<xsl:with-param name="time">
							<xsl:value-of select="$toTime"/>
						</xsl:with-param>
					</xsl:call-template>
				</xsl:if>				
				</xsl:if>
				<!---->
				<!-- Duration -->
				<xsl:if test="$duration !=''">
					<xsl:element name="Duration">
						<xsl:value-of select="$duration"/>
					</xsl:element>
				</xsl:if>
			</xsl:element>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
