<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<requests>
			<xsl:for-each select="/*/recordset/transaction">
				<xsl:choose>
					<xsl:when test="@name='sessionvars'">
						<xsl:for-each select="datamap/data/row">
							<request>
								<xsl:for-each select="col">
									<xsl:variable name="colName" select="@name"/>
									<param name="{$colName}">
										<xsl:value-of select="."/>
									</param>
								</xsl:for-each>
							</request>
						</xsl:for-each>
					</xsl:when>
					<xsl:otherwise>
						<soap:Envelope>
							<soap:Header>
								<SessionHeader xmlns="urn:foo.soap.bar.com">
									<sessionId>4I1yNabX_5FyOGOnuFO64VpRP079_jXlNKOSU</sessionId>
								</SessionHeader>
							</soap:Header>
							<soap:Body>
								<update xmlns="urn:foo.soap.bar.com">
									<sObjects>
										<type xmlns="urn:foo1.foo.soap.bar.com">Opportunity</type>
										<xsl:for-each select="datamap/data/row">
											<xsl:for-each select="col">
												<xsl:variable name="colName" select="@name"/>
												<xsl:if test="$colName='OpportunityID'">
													<Id>
														<xsl:value-of select="."/>
													</Id>
												</xsl:if>
												<xsl:if test="$colName='ExpirationDate'">
													<Expiration_Date__c xmlns="">
														<xsl:value-of select="."/>
													</Expiration_Date__c>
												</xsl:if>
											</xsl:for-each>
										</xsl:for-each>
									</sObjects>
								</update>
							</soap:Body>
						</soap:Envelope>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:for-each>
		</requests>
	</xsl:template>
</xsl:stylesheet>
