<?xml version="1.0" encoding="iso-8859-1"?>
<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="/">
    <OIT>
      <xsl:apply-templates select="DMI/Load"/>
	  <xsl:apply-templates select="DMI/Delete"/>
	  <xsl:apply-templates select="DMI/Move"/>
	  <xsl:apply-templates select="DMI/Archive"/>
    </OIT>
  </xsl:template>

  <xsl:template name="ApplicationData">
  	<xsl:attribute name="id">WinBEAT</xsl:attribute>
	<xsl:attribute name="version">
	<xsl:value-of select="../../../Header/AppVersion"/>
	</xsl:attribute>
	<xsl:attribute name="xslversion">1.0.0</xsl:attribute>
	<xsl:attribute name="database">
	<xsl:value-of select="../../../Header/Database"/>
	</xsl:attribute>
  </xsl:template>

  <xsl:template name="ApplicationData-Move">
  	<xsl:attribute name="id">WinBEAT</xsl:attribute>
	<xsl:attribute name="version">
	<xsl:value-of select="../../Header/AppVersion"/>
	</xsl:attribute>
	<xsl:attribute name="xslversion">1.0.0</xsl:attribute>
	<xsl:attribute name="database">
	<xsl:value-of select="../../Header/Database"/>
	</xsl:attribute>
  </xsl:template>

   <xsl:template name="ApplicationData-Inner">
  	<xsl:attribute name="id">WinBEAT</xsl:attribute>
	<xsl:attribute name="version">
	<xsl:value-of select="../../../../Header/AppVersion"/>
	</xsl:attribute>
	<xsl:attribute name="xslversion">1.0.0</xsl:attribute>
	<xsl:attribute name="database">
	<xsl:value-of select="../../../../Header/Database"/>
	</xsl:attribute>
  </xsl:template>
  
  <xsl:template name="Client-Attributes">
	<Attribute>
  	  	<xsl:attribute name="id">ClientUniqueID</xsl:attribute>
	  	<xsl:attribute name="value">
		<xsl:value-of select="UniqueID"/>
		</xsl:attribute>
	</Attribute>
	
	<Attribute>
		<xsl:attribute name="id">ClientCode</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Code"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientName</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Name"/>
		</xsl:attribute>
	</Attribute>
	
	<Attribute>
		<xsl:attribute name="id">ClientAddress1</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Address1"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientAddress2</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Address2"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientAddress3</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Address3"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientPostCode</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="PostCode"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientEmail</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Email"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientServicer</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Servicer"/>
		</xsl:attribute>
	</Attribute>
	
	<Attribute>
		<xsl:attribute name="id">ClientSubInter</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="SubInter"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientPhone</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Phone"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientFax</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Fax"/>
		</xsl:attribute>
	</Attribute>
	
  </xsl:template>
	
  <xsl:template name="Policy-Attributes">
 	<Attribute>
		<xsl:attribute name="id">ClientUniqueID</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="ClientUniqueID"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientCode</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="ClientCode"/>
		</xsl:attribute>
	</Attribute>
	
	<Attribute>
		<xsl:attribute name="id">Cover</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="CoverNumber/Cover"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">Version</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="CoverNumber/Version"/>
		</xsl:attribute>
	</Attribute>	

	<Attribute>
		<xsl:attribute name="id">PolicyNumber</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="PolicyNumber"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">InvoiceNumber</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="InvoiceNumber"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">OldPolicyNumber</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="OldPolicyNumber"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">Underwriter</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Underwriter"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">Class</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Class"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClassDescription</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="ClassDescription"/>
		</xsl:attribute>
	</Attribute>
  </xsl:template>

  <xsl:template name="Claim-Attributes">
  	<Attribute>
		<xsl:attribute name="id">ClientUniqueID</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="ClientUniqueID"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientCode</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="ClientCode"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">Cover</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="CoverNumber/Cover"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">Version</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="CoverNumber/Version"/>
		</xsl:attribute>
	</Attribute>
	
	<Attribute>
		<xsl:attribute name="id">ClaimNumber</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="ClaimNumber"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">UWClaimNumber</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="UWClaimNumber"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">AltClaimNumber</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="AltClaimNumber"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">Underwriter</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Underwriter"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">Class</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Class"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClassDescription</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="ClassDescription"/>
		</xsl:attribute>
	</Attribute>
  </xsl:template>

  <xsl:template name="Delete-Archive-Attributes">
  	<Attribute>
		<xsl:attribute name="id">ClientUniqueID</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="UniqueID"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientCode</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Code"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientSubInter</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="SubInter"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientServicer</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Servicer"/>
		</xsl:attribute>
	</Attribute>
  </xsl:template>

  <xsl:template name="Move-Attributes">
  	<Attribute>
		<xsl:attribute name="id">ClientUniqueID</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="UniqueID"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientOldCode</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="OldCode"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientNewCode</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="NewCode"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientSubInter</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="SubInter"/>
		</xsl:attribute>
	</Attribute>

	<Attribute>
		<xsl:attribute name="id">ClientServicer</xsl:attribute>
		<xsl:attribute name="value">
		<xsl:value-of select="Servicer"/>
		</xsl:attribute>
	</Attribute>
  </xsl:template>
  
  <xsl:template match="Load">
  	<xsl:for-each select="Associates/Associate">
	<xsl:if test= "Type='C'">
      <data>
	  	<application>
		  <xsl:call-template name="ApplicationData"/>
		</application>
		<entities>
		  <entity>
			<xsl:attribute name="type">Client</xsl:attribute>
			<xsl:attribute name="action">CreatedOrModified</xsl:attribute>
		  </entity>
		</entities>
		<Attributes>
		  <xsl:call-template name="Client-Attributes">
		  </xsl:call-template>
	  	</Attributes>
	  </data>
	  <xsl:for-each select="Policy">
	    <data>
	      <application>
		    <xsl:call-template name="ApplicationData-Inner"/>
		  </application>
		  <entities>
		    <entity>
			  <xsl:attribute name="type">Policy</xsl:attribute>
			  <xsl:attribute name="action">CreatedOrModified</xsl:attribute>
		    </entity>
		  </entities>
		  <Attributes>
		    <xsl:call-template name="Policy-Attributes">
		    </xsl:call-template>
		  </Attributes>
	    </data>
	  </xsl:for-each>
	  <xsl:for-each select="Claim">
	    <data>
	      <application>
		    <xsl:call-template name="ApplicationData-Inner"/>
		  </application>
		  <entities>
		    <entity>
			  <xsl:attribute name="type">Claim</xsl:attribute>
			  <xsl:attribute name="action">CreatedOrModified</xsl:attribute>
		    </entity>
		  </entities>
		  <Attributes>
		    <xsl:call-template name= "Claim-Attributes">
		    </xsl:call-template>
		  </Attributes>
	    </data>
	  </xsl:for-each>
	  </xsl:if>
	</xsl:for-each>

	<xsl:for-each select="Policies/Policy">
	  <data>
		<application>
		  <xsl:call-template name="ApplicationData"/>
		</application>
		<entities>
		  <entity>
			<xsl:attribute name="type">Policy</xsl:attribute>
			<xsl:attribute name="action">CreatedOrModified</xsl:attribute>
		  </entity>
		</entities>
		<Attributes>
		  <xsl:call-template name="Policy-Attributes"/>
		</Attributes>
	  </data>
	</xsl:for-each>

	<xsl:for-each select="Claims/Claim">
	  <data>
		<application>
		  <xsl:call-template name="ApplicationData"/>
		</application>
		<entities>
		  <entity>
			<xsl:attribute name="type">Claim</xsl:attribute>
			<xsl:attribute name="action">CreatedOrModified</xsl:attribute>
		  </entity>
		</entities>
		<Attributes>
		  <xsl:call-template name="Claim-Attributes"/>			
		</Attributes>
	  </data>
	</xsl:for-each>
  </xsl:template>

  <xsl:template match="Delete">
	<xsl:for-each select="Associates/Associate">
	<xsl:if test= "Type='C'">
	  <data>
		<application>
		  <xsl:call-template name="ApplicationData"/>
		</application>
		<entities>
		  <entity>
		    <xsl:attribute name="type">Client</xsl:attribute>
			<xsl:attribute name="action">Deleted</xsl:attribute>
		  </entity>
		</entities>
		<Attributes>
		  <xsl:call-template name="Delete-Archive-Attributes"/>
		</Attributes>
	  </data>
	  </xsl:if>
	</xsl:for-each>
  </xsl:template>

  <xsl:template match="Move">
  	<xsl:for-each select="Transfer-Detail">
  	  <data>
		<application>
		  <xsl:call-template name="ApplicationData-Move"/>
	    </application>
	    <entities>
		  <entity>
		    <xsl:attribute name="type">Client</xsl:attribute>
			<xsl:attribute name="action">Moved</xsl:attribute>
		  </entity>
	    </entities>
	    <Attributes>
		  <xsl:call-template name="Move-Attributes"/>
	    </Attributes>
	    </data>
	</xsl:for-each>
  </xsl:template>

   <xsl:template match="Archive">
	<xsl:for-each select="Associates/Associate">
	<xsl:if test= "Type='C'">
	  <data>
		<application>
		  <xsl:call-template name="ApplicationData"/>
		</application>
		<entities>
		  <entity>
		    <xsl:attribute name="type">Client</xsl:attribute>
			<xsl:attribute name="action">Archived</xsl:attribute>
		  </entity>
		</entities>
		<Attributes>
		  <xsl:call-template name="Delete-Archive-Attributes"/>
		</Attributes>
	  </data>
	</xsl:if>
	</xsl:for-each>
  </xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2008. Progress Software Corporation. All rights reserved.

<metaInformation>
	<scenarios>
		<scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="..\..\..\XML_WorkingFolder\WinBEAT\xml\wboit_archive.xml" htmlbaseurl="" outputurl="result1.xml" 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"/>
		<MapperBlockPosition></MapperBlockPosition>
		<TemplateContext></TemplateContext>
		<MapperFilter side="source"></MapperFilter>
	</MapperMetaTag>
</metaInformation>
-->