<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="/">
		<frame>
			<xsl:for-each select="NewDataSet/Table">
				<Policy>
					<ID>
						<xsl:value-of select="PolicyID"/>
					</ID>
					<ClientID>
						<xsl:value-of select="ClientID"/>
					</ClientID>

					<!-- Call Split Template first time, append a comma so that the last value will be take too -->
					<xsl:call-template name="splitbycomma">
						<xsl:with-param name="string" select="concat(PolicyDetailsID,',')"/>
						<xsl:with-param name="lobstring" select="concat(LOBID,',')"/>
					</xsl:call-template>
				</Policy>
			</xsl:for-each>
		</frame>
	</xsl:template>

	<!-- Split Template -->
	<xsl:template name="splitbycomma">
		<xsl:param name="string"/>
		<xsl:param name="lobstring"/>

		<xsl:choose>
			<xsl:when test="contains($string,',')">

				<!-- Create Policy Detail with current substring -->
				<xsl:element name="PolicyDetail">
					<xsl:attribute name="pdid">
						<xsl:value-of select="substring-before($string,',')"/>
					</xsl:attribute>

					<xsl:attribute name="lobid">
						<xsl:value-of select="substring-before($lobstring,',')"/>
					</xsl:attribute>
				</xsl:element>

				<!-- Recursion -->
				<xsl:call-template name="splitbycomma">
					<xsl:with-param name="string" select="substring-after($string,',')"/>
					<xsl:with-param name="lobstring" select="substring-after($lobstring,',')"/>
				</xsl:call-template>

			</xsl:when>
		</xsl:choose>
	</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="yes" externalpreview="no" url="..\..\..\..\temp\Untitled2.xml" htmlbaseurl="" outputurl="" processortype="custom" useresolver="no" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="java Xi30Xslt %1 %2 %3" additionalpath="" additionalclasspath="${classpath};C:\Program Files\Stylus Studio 2007 XML Enterprise Suite\bin\xi30xslt.jar;\\Itg01\all\Appl_Dev\Swarovski_Konzept_&amp;_Design\Projekte\XI Setup\EDI Migration\Tools\SwaTools\SwaTools.jar;\\Itg01\all\Appl_Dev\Swarovski_Konzept_&amp;_Design\Projekte\XI Setup\EDI Migration\Tools\SeeTools\SeeFunctionsXI.jar;\\Itg01\all\Appl_Dev\Swarovski_Konzept_&amp;_Design\Projekte\XI Setup\EDI Migration\Tools\SeeTools\SeeXICommonCollection.jar" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->