<?xml version="1.0"?>
<!--
@author Last Changed:$Author: theegarten $
@version $Revision: 5244 $
@date $Date: 2010-10-26 14:12:36 +0200 (Di, 26 Okt 2010) $
-->
<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:java="http://xml.apache.org/saxon/java" xmlns:xd="http://www.pnp-software.com/XSLTdoc" xmlns:tfs="http://www.infor.com/tfs" exclude-result-prefixes="java tfs">
	<!---->
	<!--****************************************************************************************************-->
	<!-- retrieves the internal shipTo from the partner mapping -->
	<!--****************************************************************************************************-->
	<xd:doc>
		<xd:short>Returns the Partner mapping for a <b>Sender</b>, <b>Receiver</b> and <b>Warehouse</b>.</xd:short>
		<xd:detail>If the <b>buyer</b> is passed as an argument to this function, it will be added to the search criteria for the Partner mapping.<br/>
		If no value was found in the Partner mapping with the passed key values, the transformation is aborted and an error is raised.
		</xd:detail>
		<xd:param name="UNBSender" type="String">Sender of the EDI message.</xd:param>
		<xd:param name="UNBReceiver" type="String">Receiver of the EDI message.</xd:param>
		<xd:param name="EDIShipTo" type="String">EDI ShipTo.</xd:param>
	</xd:doc>
	<xsl:function name="tfs:getEDLCode" as="element()*">
		<xsl:param name="MessageType"/>
		<xsl:param name="UNBSender"/>
		<xsl:param name="UNBReceiver"/>
		<xsl:param name="EDIShipTo"/>
		<!---->
		<xsl:variable name="partner" select="document('partnerMappingExternalInternal.xml')/PartnerMappingExternalInternal/Partner[@MessageType=$MessageType and @UNBSender=$UNBSender and @UNBReceiver=$UNBReceiver]/EDLCode[@id=$EDIShipTo]"/>
		<xsl:sequence select="$partner"/>
		<!-- check if partner is empty -->
<!--		<xsl:choose>
			<xsl:when test="$partner !='' ">
				<xsl:sequence select="$partner"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:message select="tfs:raiseError('Could not find a mapping for EDL code with:', $UNBSender, $UNBReceiver)"/>
			</xsl:otherwise>
		</xsl:choose>-->
	</xsl:function>
</xsl:stylesheet>
