﻿<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<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:decimal-format decimal-separator="," grouping-separator=" " />
	<xsl:template match="/">
		<html>
			<head>
				<title/>
				<meta http-equiv="X-UA-Compatible" content="IE=5"/>
				<style type="text/css">
					@page 
					{ 
					margin-left:0.6in; 
					margin-right:0.6in; 
					margin-top:0.79in; 
					margin-bottom:0.79in 
					} 
				</style>
				<style>
					td
					{padding-top:1px;
					padding-right:3px;
					padding-bottom:1px;
					padding-left:3px;
					color:windowtext;
					font-size:9pt;
					font-weight:400;
					font-style:normal;
					text-decoration:none;
					font-family:"Arial";					
					vertical-align:center;
					color:#191970;
					word-wrap:break-word;}
					tr
					{height:20}
					
				</style>
			</head>
			<body>
				<xsl:for-each select="$XML1">
					<xsl:for-each select="RTS_DOC">
						
							<xsl:for-each select="CBR_POSITION">
								<table width="100%" style="color=#191970;  word-wrap:break-word; border:0; border-bottom:0; border-collapse:collapse; border-left:0; border-right:0;" border="1">
									<tr>
										<td colspan="9" style="text-align: center; font-size:14; font-weight:bold;">
											<xsl:text>Отчет о позициях участников за </xsl:text>
											<xsl:for-each select="@ReportDate">
												<xsl:variable name="seqContentStrings_0">
													<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_0" select="string($seqContentStrings_0)"/>
												<xsl:value-of select="$sContent_0"/>
											</xsl:for-each>
										</td>
									</tr>
								</table>
								<xsl:for-each select="FIRM">
									<table width="100%" style="background=#FFFAF0; word-wrap:break-word; border:0; border-bottom:0; border-collapse:collapse; border-left:0; border-right:0;" border="1">
										<tr height="20" style="background=#CFCED9; text-align:center;">
											<td width="20%">
												<xsl:text>Уч. клиринга</xsl:text>
											</td>
											<td width="40%"> 
												<xsl:text>Наим. уч. клиринга</xsl:text>
											</td>
											<td>
												<xsl:text>ИНН уч. клиринга</xsl:text>
											</td>
										</tr>
										<tr height="20" style="background=#CFCED9; text-align:center;">
											<td style="font-weight:bold">
												<xsl:for-each select="@FirmID">
													<xsl:value-of select="string(.)"/>
												</xsl:for-each>
											</td>
											<td style="font-weight:bold">
												<xsl:for-each select="@FirmName">
													<xsl:value-of select="string(.)"/>
												</xsl:for-each>
											</td>
											<td style="font-weight:bold">
												<xsl:for-each select="@FirmDetails">
													<xsl:value-of select="string(.)"/>
												</xsl:for-each>
											</td>
										</tr>
									</table>
									<table width="100%" style="background=#FFFAF0; word-wrap:break-word; border:0; border-bottom:0; border-collapse:collapse; border-left:0; border-right:0;" border="1">
										<tr height="20" style="background=#CFCED9; text-align:center;">
											<td width="8%">
												<xsl:text>Дата исполнения</xsl:text>
											</td>
											<td width="15%">
												<xsl:text>Инф. о нетто об./треб.</xsl:text>
											</td>
											<td width="8%">
												<xsl:text>Валюта расчетов</xsl:text>
											</td>
											<td  width="8%">
												<xsl:text>ID инстр.</xsl:text>
											</td>
											<td width="15%">
												<xsl:text>Кр. наим. инстр.</xsl:text>
											</td>
											<td width="8%">
												<xsl:text>ISIN инстр.</xsl:text>
											</td>
											<td width="8%">
												<xsl:text>Код гос. рег. ЦБ</xsl:text>
											</td>
											<td width="15%">
												<xsl:text>Итоговое нетто об-во</xsl:text>
											</td>
											<td  width="15%">
												<xsl:text>Итоговое нетто треб-е</xsl:text>
											</td>
											</tr>
												<xsl:for-each select="SETTLEDATE">
													<xsl:for-each select="POSTYPES">
														<xsl:for-each select="RECORDS">
													<tr>														
														<td >
															<xsl:for-each select="../../@SettleDate">															
																	<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"/>
															</xsl:for-each>
														</td>
														<td style="text-align:right;">
															<xsl:choose>
																<xsl:when test="../@PosType='C'">
																	<xsl:text>по денежной позиции</xsl:text>
																</xsl:when>
																<xsl:when test="../@PosType='S'">
																	<xsl:text>по депозитарным разделам</xsl:text>
																</xsl:when>
															</xsl:choose>															
														</td>
														<td  style="text-align:center">
															<xsl:for-each select="@CurrencyId">
																<xsl:value-of select="string(.)"/>
															</xsl:for-each>
														</td>
														<td>
															<xsl:for-each select="@SecurityId">
																<xsl:value-of select="string(.)"/>
															</xsl:for-each>
														</td>
														<td>
															<xsl:for-each select="@SecShortName">
																<xsl:value-of select="string(.)"/>
															</xsl:for-each>
														</td>
														<td>
															<xsl:for-each select="@SecISIN">
																<xsl:value-of select="string(.)"/>
															</xsl:for-each>
														</td>
														<td>
															<xsl:for-each select="@SecRegNum">
																<xsl:value-of select="string(.)"/>
															</xsl:for-each>
														</td>
														<td>
															<xsl:for-each select="@Debit">
																<xsl:value-of select="string(.)"/>
															</xsl:for-each>
														</td>
														<td>
															<xsl:for-each select="@Credit">
																<xsl:value-of select="string(.)"/>
															</xsl:for-each>
														</td>
													</tr>
													</xsl:for-each>
												</xsl:for-each>
											</xsl:for-each>
										<tr height="20" style="background=#CFCED9; text-align:center;">
											<td colspan="9">
												<xsl:text>Итоговая информация</xsl:text>
											</td>											
										</tr>
										
									<xsl:for-each select="TOTAL">
										<xsl:for-each select="POSTYPES">
											<xsl:for-each select="RECORDS">
												<tr>
													<td colspan="2" style="text-align:right;">
														<xsl:choose>
															<xsl:when test="../@PosType='C'">
																<xsl:text>по денежной позиции</xsl:text>
															</xsl:when>
															<xsl:when test="../@PosType='S'">
																<xsl:text>по депозитарным разделам</xsl:text>
															</xsl:when>
														</xsl:choose>
													</td>
													<td  style="text-align:center">
														<xsl:for-each select="@CurrencyId">
															<xsl:value-of select="string(.)"/>
														</xsl:for-each>
													</td>
													<td>
														<xsl:for-each select="@SecurityId">
															<xsl:value-of select="string(.)"/>
														</xsl:for-each>
													</td>
													<td>
														<xsl:for-each select="@SecShortName">
															<xsl:value-of select="string(.)"/>
														</xsl:for-each>
													</td>
													<td>
														<xsl:for-each select="@SecISIN">
															<xsl:value-of select="string(.)"/>
														</xsl:for-each>
													</td>
													<td>
														<xsl:for-each select="@SecRegNum">
															<xsl:value-of select="string(.)"/>
														</xsl:for-each>
													</td>
													<td>
														<xsl:for-each select="@Debit">
															<xsl:value-of select="string(.)"/>
														</xsl:for-each>
													</td>
													<td>
														<xsl:for-each select="@Credit">
															<xsl:value-of select="string(.)"/>
														</xsl:for-each>
													</td>
												</tr>
											</xsl:for-each>
										</xsl:for-each>
									</xsl:for-each>
									</table>
									<br/>
								</xsl:for-each>
										
									
									
								<!--
										<table width="100%" style="color=#191970; font-size:9 word-wrap:break-word; border:0; border-bottom:0; border-collapse:collapse; border-left:0; border-right:0;" border="1">
										<tr height="20" style="background=#CFCED9; text-align:center;">
											<td style="font-weight:bold;">
												<xsl:text>Код УК</xsl:text>
											</td>
											<td style="font-weight:bold;">
												<xsl:text>Кр. наим. УК</xsl:text>
											</td>
											<td style="font-weight:bold;">
												<xsl:text>ИНН+БИК УК</xsl:text>
											</td>
											<td style="font-weight:bold;">
												<xsl:text>Валюта обеспечения</xsl:text>
											</td>
											<td style="font-weight:bold;">
												<xsl:text>Средства обеспечения</xsl:text>
											</td>
											<td style="font-weight:bold;">
												<xsl:text>Заблокированное ГО</xsl:text>
											</td>
											<td style="font-weight:bold;">
												<xsl:text>Сумма требования</xsl:text>
											</td>										
										</tr>
										<xsl:for-each select="FIRM">																					
											<tr>
												<xsl:for-each select="COLLATERAL">
											<td style="text-align: center">
												<xsl:value-of select="../@FirmID"/>
											</td>
											<td style="text-align: left">
												<xsl:value-of select="../@FirmName"/>
											</td>
											<td style="text-align: center">
												<xsl:value-of select="../@FirmDetails"/>
											</td>
											<td style="text-align: center">
												<xsl:value-of select="@CollateralCurrencyId"/>															
											</td>
											<td style="text-align: right">
												<xsl:value-of select="@CollateralSum"/>
											</td>
											<td style="text-align: right">
												<xsl:value-of select="@CollateralBlocked"/>
											</td>
										</xsl:for-each>
										<xsl:choose>
											<xsl:when test="OBLIGATION">
												<xsl:for-each select="OBLIGATION">
													<td style="text-align: right">
														<xsl:value-of select="@MarginCallSum"/>
													</td>
												</xsl:for-each>
											</xsl:when>
											<xsl:otherwise>
												<td></td>
											</xsl:otherwise>
										</xsl:choose>
									</tr>
								</xsl:for-each>
							</table>
							-->
								
						</xsl:for-each>
					</xsl:for-each>
				</xsl:for-each>					
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>
