<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:output method="xml" indent="yes" encoding="ISO-8859-1"/>
	<xsl:strip-space elements="*"/>

	<xsl:template match="/">
		<xsl:apply-templates select="AccountRequest"/>
	</xsl:template>

	<xsl:template match="AccountRequest">
		<OIT>
			<xsl:apply-templates select="Accounts"/>
		</OIT>
	</xsl:template>

	<xsl:template match="Accounts">
		<xsl:apply-templates select="Account"/>
	</xsl:template>

	<xsl:template match="Account">
		<xsl:if test="AccountAction='Account'">
			<data>
				<application>
					<xsl:attribute name="id">SalesForceCRM</xsl:attribute>
					<xsl:attribute name="version">1.0</xsl:attribute>
					<xsl:attribute name="xslversion">1.0.0</xsl:attribute>
					<xsl:attribute name="database">Default</xsl:attribute>
				</application>
				<entities>
					<xsl:variable name="empty_string"/>
					<xsl:choose>
						<xsl:when test="TypeDetail=$empty_string or not(TypeDetail)">
							<entity>
								<xsl:attribute name="type">
									<xsl:value-of select="AccountRecordType"/>
								</xsl:attribute>
								<xsl:attribute name="action">CreatedOrModified</xsl:attribute>
							</entity>
						</xsl:when>
						<xsl:otherwise>
							<entity>
								<xsl:attribute name="type">
									<xsl:value-of select="TypeDetail"/>
								</xsl:attribute>
								<xsl:attribute name="action">CreatedOrModified</xsl:attribute>
							</entity>
						</xsl:otherwise>
					</xsl:choose>
				</entities>

				<xsl:for-each select="node()">
					<xsl:if test="name(.)!='Cases'">
						<xsl:if test="name(.)!='AccountAction'">
							<Attribute>
								<xsl:attribute name="id">
									<xsl:value-of select="local-name(.)"/>
								</xsl:attribute>
								<xsl:attribute name="value">
									<xsl:value-of select="node()"/>
								</xsl:attribute>																 
							</Attribute>
						</xsl:if>
					</xsl:if>
				</xsl:for-each>
				<Attribute id="CaseID" value=""></Attribute>	
				<Attribute id="CaseStatus" value=""></Attribute>			
			</data>
		</xsl:if>
		<xsl:if test="AccountAction='Case'">
			<xsl:for-each select="Cases/Case">

				<data>
					<application>
						<xsl:attribute name="id">Steadfast</xsl:attribute>
						<xsl:attribute name="version">1.0</xsl:attribute>
						<xsl:attribute name="xslversion">1.0.0</xsl:attribute>
						<xsl:attribute name="database">Default</xsl:attribute>
					</application>
					<entities>
						<entity type="Case" action="CreatedOrModified"></entity>
					</entities>


					<xsl:for-each select="../../node()">
						<xsl:if test="name(.)!='Cases'">
							<xsl:if test="name(.)!='AccountAction'">
								<Attribute>
									<xsl:attribute name="id">
										<xsl:value-of select="local-name(.)"/>
									</xsl:attribute>
									<xsl:attribute name="value">
										<xsl:value-of select="node()"/>
									</xsl:attribute>
								</Attribute>
							</xsl:if>
						</xsl:if>
					</xsl:for-each>

					<xsl:for-each select="node()">
						<xsl:if test="name(.)!='Attachments'">

							<Attribute>
								<xsl:attribute name="id">
									<xsl:value-of select="local-name(.)"/>
								</xsl:attribute>
								<xsl:attribute name="value">
									<xsl:value-of select="node()"/>
								</xsl:attribute>
							</Attribute>
						</xsl:if>
					</xsl:for-each>
				</data>
			</xsl:for-each>
		</xsl:if>

		<xsl:if test="AccountAction='Attachment'">
			<xsl:for-each select="Cases/Case">
				<xsl:for-each select="Attachments/Attachment">

					<data>
						<application>
							<xsl:attribute name="id">Steadfast</xsl:attribute>
							<xsl:attribute name="version">1.0</xsl:attribute>
							<xsl:attribute name="xslversion">1.0.0</xsl:attribute>
							<xsl:attribute name="database">Default</xsl:attribute>
						</application>
						<entities>
							<entity type="Attachment" action="CreatedOrModified"></entity>
						</entities>

						<xsl:for-each select="../../../../node()">

							<xsl:if test="name(.)!='AccountAction'">
								<xsl:if test="name(.)!='Cases'">
									<Attribute>
										<xsl:attribute name="id">
											<xsl:value-of select="local-name(.)"/>
										</xsl:attribute>
										<xsl:attribute name="value">
											<xsl:value-of select="node()"/>
										</xsl:attribute>
									</Attribute>
								</xsl:if>
							</xsl:if>
						</xsl:for-each>

						<xsl:for-each select="../../node()">

							<xsl:if test="name(.)!='Attachments'">

								<Attribute>
									<xsl:attribute name="id">
										<xsl:value-of select="local-name(.)"/>
									</xsl:attribute>
									<xsl:attribute name="value">
										<xsl:value-of select="node()"/>
									</xsl:attribute>
								</Attribute>
							</xsl:if>
						</xsl:for-each>

						<xsl:for-each select="node()">
							<xsl:if test="name(.)!='AccountAction'">
								<Attribute>
									<xsl:attribute name="id">
										<xsl:value-of select="local-name(.)"/>
									</xsl:attribute>
									<xsl:attribute name="value">
										<xsl:value-of select="node()"/>
									</xsl:attribute>
								</Attribute>
							</xsl:if>
						</xsl:for-each>
					</data>
				</xsl:for-each>
			</xsl:for-each>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2008. Progress Software Corporation. All rights reserved.

<metaInformation>
	<scenarios>
		<scenario default="yes" name="Scenario111" userelativepaths="yes" externalpreview="no" url="..\Accountcreate.xml" htmlbaseurl="" outputurl="" processortype="msxmldotnet" useresolver="no" profilemode="0" profiledepth="" profilelength=""
		          urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal"
		          customvalidator="">
			<advancedProp name="sInitialMode" value=""/>
			<advancedProp name="bXsltOneIsOkay" value="true"/>
			<advancedProp name="bSchemaAware" value="true"/>
			<advancedProp name="bXml11" value="false"/>
			<advancedProp name="iValidation" value="0"/>
			<advancedProp name="bExtensions" value="true"/>
			<advancedProp name="iWhitespace" value="0"/>
			<advancedProp name="sInitialTemplate" value=""/>
			<advancedProp name="bTinyTree" value="true"/>
			<advancedProp name="bWarnings" value="true"/>
			<advancedProp name="bUseDTD" value="false"/>
			<advancedProp name="iErrorHandling" value="fatal"/>
		</scenario>
		<scenario default="no" name="Scenario1" userelativepaths="yes" externalpreview="no" url="steadfast_sample02.xml" htmlbaseurl="" outputurl="" processortype="saxon8" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml=""
		          commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator="">
			<advancedProp name="sInitialMode" value=""/>
			<advancedProp name="bXsltOneIsOkay" value="true"/>
			<advancedProp name="bSchemaAware" value="true"/>
			<advancedProp name="bXml11" value="false"/>
			<advancedProp name="iValidation" value="0"/>
			<advancedProp name="bExtensions" value="true"/>
			<advancedProp name="iWhitespace" value="0"/>
			<advancedProp name="sInitialTemplate" value=""/>
			<advancedProp name="bTinyTree" value="true"/>
			<advancedProp name="bWarnings" value="true"/>
			<advancedProp name="bUseDTD" value="false"/>
			<advancedProp name="iErrorHandling" value="fatal"/>
		</scenario>
		<scenario default="no" name="Scenario2" userelativepaths="yes" externalpreview="no" url="..\xml\Steadfast_AccountCaseAttachment.xml" htmlbaseurl="" outputurl="" processortype="saxon8" useresolver="yes" profilemode="0" profiledepth=""
		          profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal"
		          customvalidator="">
			<advancedProp name="sInitialMode" value=""/>
			<advancedProp name="bXsltOneIsOkay" value="true"/>
			<advancedProp name="bSchemaAware" value="true"/>
			<advancedProp name="bXml11" value="false"/>
			<advancedProp name="iValidation" value="0"/>
			<advancedProp name="bExtensions" value="true"/>
			<advancedProp name="iWhitespace" value="0"/>
			<advancedProp name="sInitialTemplate" value=""/>
			<advancedProp name="bTinyTree" value="true"/>
			<advancedProp name="bWarnings" value="true"/>
			<advancedProp name="bUseDTD" value="false"/>
			<advancedProp name="iErrorHandling" value="fatal"/>
		</scenario>
	</scenarios>
	<MapperMetaTag>
		<MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no">
			<SourceSchema srcSchemaPath="steadfast_sample02.xml" srcSchemaRoot="AccountRequest" AssociatedInstance="" loaderFunction="document" loaderFunctionUsesURI="no"/>
		</MapperInfo>
		<MapperBlockPosition>
			<template match="/"></template>
			<template match="AccountRequest">
				<block path="OIT/xsl:apply-templates" x="209" y="18"/>
			</template>
			<template match="Accounts"></template>
		</MapperBlockPosition>
		<TemplateContext></TemplateContext>
		<MapperFilter side="source"></MapperFilter>
	</MapperMetaTag>
</metaInformation>
-->