<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:b="urn:OEXML:r1" 
xmlns:a="http://www.siebel.com/xml/OE%20EAI%20Obtain%20Standing%20Data" 
xmlns:func="http://exslt.org/functions" 
xmlns:Ext="d://oexml//test_lov//test_lov2.xsl"> 
<xsl:output method="xml" encoding="UTF-16"/>
	<!--<xsl:variable name="LOV_Value" select="."/>-->
	<func:function name="Ext:transform_lov">
		<xsl:param name="Node"/>
		<xsl:param name="LOV_Field_Value"/>
		<xsl:param name="Interface_Direction"/>
			<xsl:variable name="value-pick" select="document('d:/oexml/test_lov/eai_value_map.xml')/root"/>
			<xsl:variable name="LOV_String" select="$Node"/>
			<xsl:variable name="LOV_Field" select="substring-after($LOV_String,'__')"/>
			<xsl:variable name="LOV_Type" select="substring($LOV_String,5,string-length($LOV_String) - 4 - string-length($LOV_Field)-2)"/>
			<xsl:variable name="Transformed_Value" select="$value-pick/row[Direction = $Interface_Direction and Type = $LOV_Type and External_System_Value = $LOV_Field_Value]/Siebel_Value"/>
		<func:result select="$Transformed_Value"/>
	</func:function>
	<xsl:template match="*">
		<xsl:variable name="Interface_Direction" select="'Interface Direction cannot be determined'"/>
		<xsl:variable name="Message_Id"> <xsl:value-of select="MessageID"/>
		</xsl:variable>
		<xsl:copy>
		<xsl:choose>
			<xsl:when test="starts-with(name(),'LOV_')">
				<xsl:variable name="LOV_Field_Value" select="."/>
				<xsl:choose>
					<xsl:when test="contains($Message_Id,'-Req')">
						<xsl:variable name="Interface_Direction" select="'Siebel Outbound'"/>
		  			</xsl:when>
					<xsl:when test="contains($Message_Id,'-Resp')">
						<xsl:variable name="Interface_Direction" select="'Siebel Inbound'"/>
		  			</xsl:when>
					<xsl:otherwise>
						<xsl:variable name="Interface_Direction" select="'Interface Direction cannot be determined'"/>
		  			</xsl:otherwise>
				</xsl:choose>
				<xsl:value-of select="Ext:transform_lov(name(), $LOV_Field_Value, $Interface_Direction)"/>
	  		</xsl:when>
			<xsl:otherwise>
				<xsl:copy-of select="@*"/>
				<xsl:apply-templates select="*|text()"/>
		  	</xsl:otherwise>
		</xsl:choose>
		</xsl:copy>
	</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="no" externalpreview="no" url="file:///d:/oexml/test_lov/test_a1.xml" htmlbaseurl="" outputurl="file:///d:/oexml/test_lov/test_xx.xml" processortype="xalan" 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="..\dest.xsd" destSchemaRoot="SiebelMessage" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no" ><SourceSchema srcSchemaPath="..\oexml_r1.xsd" srcSchemaRoot="OEXML" AssociatedInstance="file:///d:/oexml/test_a1.xml" loaderFunction="document" loaderFunctionUsesURI="no"/></MapperInfo><MapperBlockPosition><template match="/"><block path="a:SiebelMessage/xsl:attribute[1]/xsl:for&#x2D;each/xsl:if/=[0]" x="217" y="70"/><block path="a:SiebelMessage/xsl:attribute[1]/xsl:for&#x2D;each/xsl:if" x="263" y="72"/></template></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->