<?xml version="1.0"?>
<!--
@author Last Changed:$Author: theegarten $
@version $Revision: 4772 $
@date $Date: 2010-09-06 15:04:22 +0200 (Mo, 06 Sep 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">
    
    <xsl:template name="Sync">
        <!---->
        <!-- parameter -->
        <xsl:param name="tenantID"/>
        <xsl:param name="accountingEntityID"/>
        <xsl:param name="locationID"/>
        <xsl:param name="action"/>
        <!---->
        <!-- variables -->
        <!-- set TenantID -->
        <xsl:variable name="tenantIDInt">
            <xsl:choose>
                <xsl:when test="$tenantID != ''">
                    <xsl:value-of select="$tenantID"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="'#TENANTID#'"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!-- set AccountingEntityID -->
        <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>
        <!-- set LocationID -->
        <xsl:variable name="locationIDInt">
            <xsl:choose>
                <xsl:when test="$locationID != ''">
                    <xsl:value-of select="$locationID"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="'#LOCATIONID#'"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <!-- set ActionCriteria -->
        <xsl:variable name="actionInt">
            <xsl:choose>
                <xsl:when test="$action != ''">
                    <xsl:value-of select="$action"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="'Add'"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:element name="Sync">
            <xsl:element name="TenantID">
                <xsl:value-of select="$tenantIDInt"/>
            </xsl:element>
            <xsl:element name="AccountingEntityID">
                <xsl:value-of select="$accountingEntityIDInt"/>
            </xsl:element>
            <xsl:element name="LocationID">
                <xsl:value-of select="$locationIDInt"/>
            </xsl:element>
            <xsl:element name="ActionCriteria">
                <xsl:element name="ActionExpression">
                    <xsl:attribute name="actionCode"><xsl:value-of select="$actionInt"/></xsl:attribute>
                </xsl:element>
            </xsl:element>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>
