﻿<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:clitype="clitype" xmlns:fn="http://www.w3.org/2005/xpath-functions"
	xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL"
	xmlns:java="java" xmlns:link="http://www.xbrl.org/2003/linkbase"
	xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:xbrli="http://www.xbrl.org/2003/instance"
	xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<xsl:output version="4.0" method="html" indent="no" encoding="UTF-8"
		doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
	<xsl:param name="SV_OutputFormat" select="'HTML'"/>
	<xsl:variable name="XML1" select="/"/>
	<xsl:template match="/">
		<html>
			<head>
				<title/>
				<meta http-equiv="X-UA-Compatible" content="IE=5"/>

				<style>
					td
					{
					    padding-top:1px;
					    padding-right:3px;
					    padding-bottom:1px;
					    padding-left:3px;
					    color:windowtext;
					    font-size:8pt;
					    font-weight:400;
					    font-style:normal;
					    text-decoration:none;
					    font-family:"Arial";
					    text-align:general;
					    vertical-align:bottom;
					    color:#191970;
					    word-wrap:break-word;
					}</style>
			</head>
			<body>

				<xsl:for-each select="$XML1">
					<xsl:for-each select="RTS_DOC">
						<div>
							<xsl:for-each select="DOC_REQUISITES">
								<table width="70%"
									style="background=#FFFAF0; color=#191970; font-size:11; word-wrap:break-word; border:0; border-bottom:0; border-collapse:collapse; border-left:0; border-right:0;"
									border="1">

									<tr
										style="text-align:center; vertical-align:Center; word-wrap:break-word; font-size:15; font-weight:bold; color:#191970; background= #B0C4DE;">
										<th colspan="5">
											<xsl:choose>
												<xsl:when test="@SENDER_NAME!=''">
												<span>
												<xsl:value-of select="@SENDER_NAME"/>
												</span>
												</xsl:when>
												<xsl:otherwise>
												<xsl:text>International Trading System Limited (ITS Ltd.)</xsl:text>
												</xsl:otherwise>
											</xsl:choose>
										</th>
									</tr>
									<tr style="background=#E6E6FA; text-align:center;">
										<td width="27%">
											<xsl:text>Document</xsl:text>
										</td>

										<td width="7%">
											<xsl:text>Type</xsl:text>
										</td>

										<td width="15%">
											<xsl:text>DES sender code</xsl:text>
										</td>
										<td>
											<xsl:text>Receiver DES code</xsl:text>
										</td>

										<td rowspan="2"
											style="font-style:italic; text-align:left; vertical-align:top; background=#FFFAF0;">
											<span>
												<xsl:text>Text of notes to the document.: </xsl:text>
											</span>
											<xsl:for-each select="@REMARKS">
												<xsl:value-of select="string(.)"/>
											</xsl:for-each>
										</td>
									</tr>
									<tr style="text-align:center">
										<td>
											<xsl:value-of select="@DOC_NO"/>											
											<xsl:text> of </xsl:text>
											<xsl:value-of  select="@DOC_DATE"/>											
											<xsl:text> </xsl:text>
											<xsl:value-of select="@DOC_TIME"/>											
										</td>
										<td>
											<xsl:for-each select="@DOC_TYPE_ID">
												<xsl:value-of select="string(.)"/>
											</xsl:for-each>
										</td>
										<td>
											<xsl:for-each select="@SENDER_ID">
												<xsl:value-of select="string(.)"/>
											</xsl:for-each>
										</td>
										<td>
											<xsl:for-each select="@RECEIVER_ID">
												<xsl:value-of select="string(.)"/>
											</xsl:for-each>
										</td>
									</tr>

								</table>
							</xsl:for-each>
						</div>
						<xsl:for-each select="ITS82">
							<table width="100%"
								style="background=#FFFAF0; color=#191970; font-size:11; word-wrap:break-word; border:0; border-bottom:0; border-collapse:collapse; border-left:0; border-right:0;"
								border="1">
								<th colspan="8"
									style="text-align:center; vertical-align:Center; word-wrap:break-word; font-size:15; font-weight:bold; color:#191970; background= #B0C4DE;">
									<xsl:choose>
										<xsl:when test="@ReportDesc!=''">
											<span>
												<xsl:value-of select="@ReportDesc"/>
											</span>
										</xsl:when>
										<xsl:otherwise>
											<xsl:text>Notification on Registered Codes/ Short Codes of Clients and/or a Trading Member</xsl:text>
										</xsl:otherwise>
									</xsl:choose>
									<xsl:text> of </xsl:text>
									<xsl:value-of select="@ReportDate"/>									
								</th>
								<tr style="text-align:center;">
									<td width="17%" style="background=#E6E6FA;">
										<xsl:text>Report date:</xsl:text>
									</td>
									<td width="17%" style="background=#E6E6FA;" >
										<xsl:text>Report number:</xsl:text>
									</td>     
									<td width="17%" style="background=#E6E6FA;" >
										<xsl:text>Report volume:</xsl:text>
									</td> 
									<td colspan="1" width="10%" style="background=#E6E6FA;">
										<xsl:text>Trading Member ID:</xsl:text>
									</td>
									<td colspan="3" width="60%" style="background=#E6E6FA;">
										<xsl:text>Short name of the Trading Member:</xsl:text>
									</td>
									<td colspan="1" width="auto" style="background=#E6E6FA;">
										<xsl:text>Taxpayer Identification Number of the Trading Member:</xsl:text>
									</td> 
								</tr>
								<tr>
									<td colspan="1" style="text-align:center;">
										<xsl:for-each select="@ReportDate">
											<span>
												<xsl:variable name="seqContentStrings_1">
												<xsl:value-of
												select="format-number(number(substring(string(string(.)), 9, 2)), '00')"/>
												<xsl:text>-</xsl:text>
												<xsl:value-of
												select="format-number(number(substring(string(string(.)), 6, 2)), '00')"/>
												<xsl:text>-</xsl:text>
												<xsl:value-of
												select="format-number(number(substring(string(string(string(.))), 1, 4)), '0000')"
												/>
												</xsl:variable>
												<xsl:variable name="sContent_1"
												select="string($seqContentStrings_1)"/>
												<xsl:value-of select="$sContent_1"/>
											</span>
										</xsl:for-each>
										<xsl:for-each select="@Weekday">
											<span>
												<xsl:text> (</xsl:text>
												<xsl:value-of select="string(.)"/>
												<xsl:text>)</xsl:text>
											</span>
										</xsl:for-each>
									</td>
									<td  style="text-align:center;" >
										<xsl:choose>
											<xsl:when test="@ReportVersion = 2">
												<xsl:for-each select="@ReportNumber">
													<xsl:value-of select="string(.)"/>
												</xsl:for-each>
											</xsl:when>
											<xsl:otherwise>	
												<xsl:for-each select="../@DOC_NO">
													<xsl:value-of select="string(.)"/>
												</xsl:for-each>                		
												
											</xsl:otherwise>
										</xsl:choose>
									</td>
									<td  style="text-align:center;" >
										<xsl:choose>
											<xsl:when test="@ReportVersion = 2">
												
												<xsl:value-of select="@Volume"/>
												<xsl:text> of </xsl:text>
												<xsl:value-of select="@VolumeTotal"/>
											</xsl:when>
											<xsl:otherwise>	
												<xsl:text>1 of 1</xsl:text>	
											</xsl:otherwise>
										</xsl:choose>
									</td>

									<td colspan="1" style="text-align:center;">
										<xsl:for-each select="FIRM">
											<xsl:for-each select="@FirmID">
												<xsl:value-of select="string(.)"/>
											</xsl:for-each>
										</xsl:for-each>
									</td>

									<td colspan="3" style="text-align:center;">
										<xsl:for-each select="FIRM">
											<xsl:for-each select="@FirmName">
												<xsl:value-of select="string(.)"/>
											</xsl:for-each>
										</xsl:for-each>
									</td>

									<td colspan="1" style="text-align:center;">
										<xsl:for-each select="FIRM">
											<xsl:for-each select="@FirmDetails">
												<xsl:value-of select="string(.)"/>
											</xsl:for-each>
										</xsl:for-each>
									</td>

								</tr>
							</table>
							<br/>
							<xsl:choose>
								<xsl:when test="@ReportVersion =2">
									<xsl:for-each select="FIRM">
										<table width="100%"
											style="background=#FFFAF0; color=#191970; border:1; border-bottom:0; border-collapse:collapse; border-left:0; border-right:0; border-top:0; font-family:Arial; font-size:9; word-wrap:break-word;"
											border="1">
											
											<xsl:choose>
												<xsl:when test="RECORDS/@ClientCode">
													<thead
														style="text-align:center; word-wrap:break-word; ">
														
														<tr
															 style="vertical-align:top; word-wrap:break-word; color:#191970; background=#E6E6FA; ">
															<th>
																<xsl:text>Client short code</xsl:text>
															</th>
															<th>
																<xsl:text>Operation with a client</xsl:text>
															</th>
															<th>
																<xsl:text>Status of admission of a client</xsl:text>
															</th>
														</tr>
													</thead>
													
													
													<tbody>
														<xsl:for-each select="RECORDS">
															<xsl:sort select="@Status"/>
															<tr style="vertical-align:top; ">
																<td
																	style="text-align:center; ">
																	<xsl:for-each select="@ClientCode">
																		<xsl:value-of select="string(.) "/>
																	</xsl:for-each>
																</td>
																<td
																	style="text-align:center; ">
																	<xsl:choose>
																		<xsl:when test="@Status='A'">
																			<span>
																				<xsl:text>registered</xsl:text>
																			</span>
																		</xsl:when>
																		<xsl:when test="@Status='U'">
																			<span>
																				<xsl:text>updated</xsl:text>
																			</span>
																		</xsl:when>
																		<xsl:when test="@Status='D'">
																			<span>
																				<xsl:text>deleted</xsl:text>
																			</span>
																		</xsl:when>
																		<xsl:otherwise>
																			<span>
																				<xsl:text></xsl:text>
																			</span>
																		</xsl:otherwise>
																	</xsl:choose>
																</td>
																<td
																	style=" text-align:center; ">
																	<xsl:choose>
																		<xsl:when test="@AccessStatus='A'">
																			<span>
																				<xsl:text>admitted </xsl:text>
																			</span>
																		</xsl:when>
																		<xsl:when test="@AccessStatus='N' or @Status='n'">
																			<span>
																				<xsl:text>admission suspended</xsl:text>
																			</span>
																		</xsl:when>
																		<xsl:when test="@AccessStatus='D' or @Status='d'">
																			<span>
																				<xsl:text>admission terminated</xsl:text>
																			</span>
																		</xsl:when>
																		<xsl:otherwise>
																			<span>
																				<xsl:text></xsl:text>
																			</span>
																		</xsl:otherwise>
																	</xsl:choose>
																</td>
															</tr>
				
														</xsl:for-each>
														
													</tbody>
												</xsl:when>
											</xsl:choose>
										</table>
										<br/>
										
									</xsl:for-each>
								</xsl:when>
							</xsl:choose>
						</xsl:for-each>
					</xsl:for-each>
				</xsl:for-each>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>
