<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:import href="Common.xslt"/>


  <xsl:template match="//Agents">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:param name="path"/>
    <tr>
      <td>
        <span style="font-weight:bold">
          <xsl:text>Доверенные лица</xsl:text>
        </span>
      </td>
    </tr>
    <xsl:for-each select="Agent">
      <tr>
        <td>
          <table style="width:100%">
            <xsl:call-template name="Table4"/>
            <xsl:call-template name="Person">
              <xsl:with-param name="pos" select="$pos"/>
              <xsl:with-param name="part" select="$part"/>
              <xsl:with-param name="path" select="$path"/>
              <xsl:with-param name="pos0" select="$ppp"/>
              <xsl:with-param name="pos1" select="$ppp"/>
              <xsl:with-param name="pos2" select="$ppp"/>
            </xsl:call-template>
          </table>
        </td>
      </tr>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="//Object">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:param name="path"/>
    <tr>
      <td>
        <span style="font-weight:bold">
          <xsl:text>Объекты заявления</xsl:text>
        </span>
      </td>
    </tr>
    <xsl:variable name="O">
      <xsl:choose>
        <xsl:when test="Parcels">
          <xsl:text>Земельный участок</xsl:text>
        </xsl:when>
        <xsl:when test="Realty">
          <xsl:text>Недвижимость</xsl:text>
        </xsl:when>
        <xsl:when test="Blocks">
          <xsl:text>Кадастровый квартал</xsl:text>
        </xsl:when>
      </xsl:choose>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="Parcels">
        <xsl:for-each select="Parcels/Parcel">
          <tr>
            <td>
              <table style="width:100%">
                <xsl:call-template name="Table4"/>
                <tr>
                  <td colspan="4">
                    <span style="font-weight:bold">
                      <xsl:value-of select="$O"/>
                    </span>
                  </td>
                </tr>
                <xsl:call-template name="Parcel">
                  <xsl:with-param name="pos" select="$pos"/>
                  <xsl:with-param name="part" select="$part"/>
                  <xsl:with-param name="path" select="$path"/>
                </xsl:call-template>
                <!--xsl:if test="@exist='no'">
                  <tr>
                    <td>
                      <span>
                        <xsl:text>Идентификатор объекта</xsl:text>
                        <nobr>
                          <xsl:text>(в файле)</xsl:text>
                        </nobr>
                      </span>
                    </td>
                    <td colspan="3">
                      <xsl:call-template name="TextBox">
                        <xsl:with-param name="siz" select="75"/>
                        <xsl:with-param name="val" select="@temp_id"/>
                      </xsl:call-template>
                    </td>
                  </tr>
                </xsl:if-->
              </table>
            </td>
          </tr>
        </xsl:for-each>
      </xsl:when>
      <xsl:when test="Realty">
        <xsl:for-each select="Realty/Realty_Object">
          <tr>
            <td>
              <table style="width:100%">
                <xsl:call-template name="Table4"/>
                <tr>
                  <td colspan="4">
                    <span style="font-weight:bold">
                      <xsl:value-of select="$O"/>
                    </span>
                  </td>
                </tr>
                <xsl:call-template name="Realty_Object">
                  <xsl:with-param name="pos" select="$pos"/>
                  <xsl:with-param name="part" select="$part"/>
                  <xsl:with-param name="path" select="$path"/>
                </xsl:call-template>
              </table>
            </td>
          </tr>
        </xsl:for-each>
      </xsl:when>
      <xsl:when test="Blocks">
        <xsl:for-each select="Blocks/Block">
          <tr>
            <td>
              <table style="width:100%">
                <xsl:call-template name="Table4"/>
                <tr>
                  <td colspan="4">
                    <span style="font-weight:bold">
                      <xsl:value-of select="$O"/>
                    </span>
                  </td>
                </tr>
                <xsl:call-template name="Block">
                  <xsl:with-param name="pos" select="$pos"/>
                  <xsl:with-param name="part" select="$part"/>
                  <xsl:with-param name="path" select="$path"/>
                </xsl:call-template>
              </table>
            </td>
          </tr>
        </xsl:for-each>
      </xsl:when>
    </xsl:choose>
    <xsl:if test="*/AppliedFiles">
      <tr>
        <td>
          <table style="width:100%">
            <xsl:call-template name="Table4"/>
            <tr>
              <td colspan="4">
                <span style="font-weight:bold">
                  <xsl:text>Приложенные файлы</xsl:text>
                </span>
              </td>
            </tr>
            <xsl:for-each select="*/AppliedFiles/AppliedFile">
              <xsl:call-template name="AppliedFile">
                <xsl:with-param name="pos" select="$pos"/>
                <xsl:with-param name="part" select="$part"/>
                <xsl:with-param name="path" select="$path"/>
              </xsl:call-template>
            </xsl:for-each>
          </table>
        </td>
      </tr>
    </xsl:if>
  </xsl:template>

  <xsl:template match="//Applied_Documents">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:param name="path"/>
    <tr>
      <td>
        <span style="font-weight:bold">
          <xsl:text>Приложенные документы</xsl:text>
        </span>
      </td>
    </tr>
    <xsl:for-each select="Applied_Document">
      <tr>
        <td>
          <table style="width:100%">
            <xsl:call-template name="Table4"/>
            <xsl:call-template name="Document_spec">
              <xsl:with-param name="pos" select="$pos"/>
              <xsl:with-param name="part" select="$part"/>
              <xsl:with-param name="path" select="$path"/>
              <xsl:with-param name="type" select="$ttt"/>
              <xsl:with-param name="pos0" select="$ppp"/>
              <xsl:with-param name="pos1" select="$ppp"/>
              <xsl:with-param name="pos2" select="$ppp"/>
            </xsl:call-template>
          </table>
        </td>
      </tr>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="//Payment_Documents">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:param name="path"/>
    <tr>
      <td>
        <span style="font-weight:bold">
          <xsl:text>Платежные документы</xsl:text>
        </span>
      </td>
    </tr>
    <xsl:for-each select="Payment_Document">
      <tr>
        <td>
          <table style="width:100%">
            <xsl:call-template name="Table4"/>
            <tr>
              <td>
                <span>
                  <xsl:text>Назначение документа (код)</xsl:text>
                </span>
              </td>
              <td colspan="3">
                <xsl:call-template name="DictBox">
                  <xsl:with-param name="dic">
                    <xsl:call-template name="sPayDocType"/>
                  </xsl:with-param>
                  <xsl:with-param name="siz" select="75"/>
                  <xsl:with-param name="val" select="Doc_Type"/>
                </xsl:call-template>
              </td>
            </tr>
            <tr>
              <td>
                <span>
                  <xsl:text>Номер документа</xsl:text>
                </span>
              </td>
              <td colspan="3">
                <xsl:call-template name="TextBox">
                  <xsl:with-param name="siz" select="75"/>
                  <xsl:with-param name="val" select="Number"/>
                </xsl:call-template>
              </td>
            </tr>
            <tr>
              <td>
                <span>
                  <xsl:text>Дата</xsl:text>
                </span>
              </td>
              <td>
                <xsl:call-template name="DateBox">
                  <xsl:with-param name="siz" select="25"/>
                  <xsl:with-param name="val" select="Date"/>
                </xsl:call-template>
              </td>
              <td>
                <span>
                  <xsl:text>Сумма</xsl:text>
                </span>
              </td>
              <td>
                <xsl:call-template name="TextBox">
                  <xsl:with-param name="siz" select="25"/>
                  <xsl:with-param name="val" select="Sum"/>
                </xsl:call-template>
              </td>
            </tr>
            <xsl:for-each select="Images/Image">
              <xsl:choose>
                <xsl:when test="$part='!Print!'">
                  <xsl:call-template name="PictureInsert">
                    <xsl:with-param name="path" select="$path"/>
                  </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:call-template name="ImageRef">
                    <xsl:with-param name="part" select="$part"/>
                    <xsl:with-param name="type" select="$ttt"/>
                    <xsl:with-param name="pos" select="$pos"/>
                    <xsl:with-param name="pos0" select="$ppp"/>
                    <xsl:with-param name="pos1" select="$ppp"/>
                    <xsl:with-param name="pos2" select="$ppp"/>
                  </xsl:call-template>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:for-each>
          </table>
        </td>
      </tr>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="//Request_Documents">
    <tr>
      <td>
        <span style="font-weight:bold">
          <xsl:text>Запрашиваемые документы</xsl:text>
        </span>
      </td>
    </tr>
    <xsl:for-each select="Request_Document">
      <tr>
        <td>
          <table style="width:100%">
            <xsl:call-template name="Table4"/>
            <xsl:if test="@SubCode!=''">
              <tr>
                <td>
                  <span>
                    <xsl:text>Вид документа (код)</xsl:text>
                  </span>
                </td>
                <td colspan="3">
                  <xsl:call-template name="DictBox">
                    <xsl:with-param name="siz" select="75"/>
                    <xsl:with-param name="val" select="@SubCode"/>
                    <xsl:with-param name="dic">
                      <xsl:call-template name="dCad_Out_Doc_Type"/>
                      <xsl:call-template name="dAllDocuments"/>
                    </xsl:with-param>
                  </xsl:call-template>
                </td>
              </tr>
            </xsl:if>
            <xsl:if test="@Name!=''">
              <tr>
                <td>
                  <span>
                    <xsl:text>Наименование копии</xsl:text>
                  </span>
                </td>
                <td colspan="3">
                  <xsl:call-template name="TextBox">
                    <xsl:with-param name="siz" select="75"/>
                    <xsl:with-param name="val" select="@Name"/>
                  </xsl:call-template>
                </td>
              </tr>
            </xsl:if>
            <xsl:if test="Sections_KV!=''">
              <tr>
                <td>
                  <span>
                    <xsl:text>Запрашиваемые разделы (коды)</xsl:text>
                  </span>
                </td>
                <td colspan="3">
                  <xsl:call-template name="TextBox">
                    <xsl:with-param name="siz" select="75"/>
                    <xsl:with-param name="val">
                      <xsl:for-each select="Sections_KV/Section_KV">
                        <xsl:value-of select="."/>
                        <xsl:text> - </xsl:text>
                        <xsl:call-template name="Dicts">
                          <xsl:with-param name="code" select="."/>
                          <xsl:with-param name="dict">
                            <xsl:call-template name="sSection_KV"/>
                          </xsl:with-param>
                        </xsl:call-template>
                        <xsl:if test="position()!=last()">
                          <xsl:text>, </xsl:text>
                        </xsl:if>
                      </xsl:for-each>
                    </xsl:with-param>
                  </xsl:call-template>
                </td>
              </tr>
            </xsl:if>
            <xsl:if test="@PurposeKind!=''">
              <tr>
                <td>
                  <span>
                    <xsl:text>Цель предоставления (код)</xsl:text>
                  </span>
                </td>
                <td colspan="3">
                  <xsl:call-template name="DictBox">
                    <xsl:with-param name="siz" select="75"/>
                    <xsl:with-param name="val" select="@PurposeKind"/>
                    <xsl:with-param name="dic">
                      <xsl:call-template name="sPurposeKind"/>
                    </xsl:with-param>
                  </xsl:call-template>
                </td>
              </tr>
            </xsl:if>
            <xsl:if test="@PurposeKind_Text!=''">
              <tr>
                <td>
                  <span>
                    <xsl:text>Цель предоставления (текст)</xsl:text>
                  </span>
                </td>
                <td colspan="3">
                  <xsl:call-template name="TextBox">
                    <xsl:with-param name="siz" select="75"/>
                    <xsl:with-param name="val" select="@PurposeKind_Text"/>
                  </xsl:call-template>
                </td>
              </tr>
            </xsl:if>
            <xsl:if test="@Quantity!=''">
              <tr>
                <td>
                  <span>
                    <xsl:text>Количество копий</xsl:text>
                  </span>
                </td>
                <td colspan="3">
                  <xsl:call-template name="TextBox">
                    <xsl:with-param name="siz" select="75"/>
                    <xsl:with-param name="val" select="@Quantity"/>
                  </xsl:call-template>
                </td>
              </tr>
            </xsl:if>
            <xsl:if test="@Method_Accordance!=''">
              <tr>
                <td colspan="2">
                  <span>
                    <xsl:text>Способ предоставления сведений (код)</xsl:text>
                  </span>
                </td>
                <td colspan="2">
                  <xsl:call-template name="DictBox">
                    <xsl:with-param name="siz" select="50"/>
                    <xsl:with-param name="val" select="@Method_Accordance"/>
                    <xsl:with-param name="dic">
                      <xsl:call-template name="sMethodAccordance"/>
                      <xsl:call-template name="dMethodAccordance"/>
                    </xsl:with-param>
                  </xsl:call-template>
                </td>
              </tr>
            </xsl:if>
            <!--td>
                  <span>
                    <xsl:text>Идентификатор заявителя</xsl:text>
                    <nobr>
                      <xsl:text>(в файле)</xsl:text>
                    </nobr>
                  </span>
                </td>
                <td>
                  <xsl:call-template name="TextBox">
                    <xsl:with-param name="siz" select="25"/>
                    <xsl:with-param name="val" select="@declarant_id"/>
                  </xsl:call-template>
                </td!-->
            <xsl:if test="@object_id!='' and count(../../Object/Parcels/Parcel)>1">
              <tr>

                <td colspan="2">
                  <span>
                    <xsl:text>Идентификатор объекта </xsl:text>
                    <nobr>
                      <xsl:text>(в файле)</xsl:text>
                    </nobr>
                  </span>
                </td>
                <td colspan="2">
                  <xsl:call-template name="TextBox">
                    <xsl:with-param name="siz" select="50"/>
                    <xsl:with-param name="val" select="@object_id"/>
                  </xsl:call-template>
                </td>
              </tr>
            </xsl:if>
          </table>
        </td>
      </tr>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="//Out_Documents">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:param name="path"/>
    <tr>
      <td>
        <span style="font-weight:bold">
          <xsl:text>Выданные документы</xsl:text>
        </span>
      </td>
    </tr>

    <xsl:for-each select="Out_Document">
      <tr>
        <td>
          <table style="width:100%">
            <xsl:call-template name="Table4"/>
            <xsl:call-template name="Document_spec">
              <xsl:with-param name="pos" select="$pos"/>
              <xsl:with-param name="part" select="$part"/>
              <xsl:with-param name="path" select="$path"/>
              <xsl:with-param name="type" select="$ttt"/>
              <xsl:with-param name="pos0" select="$ppp"/>
              <xsl:with-param name="pos1" select="$ppp"/>
              <xsl:with-param name="pos2" select="$ppp"/>
            </xsl:call-template>
          </table>
        </td>
      </tr>
    </xsl:for-each>

  </xsl:template>

  <xsl:template match="//Current_Changes">
    <tr>
      <td>
        <span style="font-weight:bold">
          <xsl:text>Список изменений</xsl:text>
        </span>
      </td>
    </tr>
    <xsl:for-each select="Cur_Change">
      <tr>
        <td>
          <table style="width:100%">
            <xsl:call-template name="Table4"/>
            <tr>
              <td colspan="2">
                <span>
                  <xsl:text>Характеристика текущих изменений (код)</xsl:text>
                </span>
              </td>
              <td colspan="2">
                <xsl:call-template name="DictBox">
                  <xsl:with-param name="dic">
                    <xsl:choose>
                      <xsl:when test="eDocument/@Version='14'">
                        <xsl:call-template name="dCurrentChanges14"/>
                      </xsl:when>
                      <xsl:when test="eDocument/@Version='15'">
                        <xsl:call-template name="dCurrentChanges15"/>
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:call-template name="dCurrentChanges"/>
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:with-param>
                  <xsl:with-param name="siz" select="50"/>
                  <xsl:with-param name="val" select="."/>
                </xsl:call-template>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="//Information_CPTs">
    <tr>
      <td>
        <span style="font-weight:bold">
          <xsl:text>Состав сведений КПТ</xsl:text>
        </span>
      </td>
    </tr>
    <xsl:for-each select="Information_CPT">
      <tr>
        <td>
          <table style="width:100%">
            <xsl:call-template name="Table4"/>
            <tr>
              <td colspan="1">
                <span>
                  <xsl:text>Состав сведений (код)</xsl:text>
                </span>
              </td>
              <td colspan="3">
                <xsl:call-template name="DictBox">
                  <xsl:with-param name="dic">
                    <xsl:call-template name="dInformationCPT"/>
                  </xsl:with-param>
                  <xsl:with-param name="siz" select="75"/>
                  <xsl:with-param name="val" select="."/>
                </xsl:call-template>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="Parcel">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:param name="path"/>
    <xsl:if test="@exist!='' or @Name!=''">
      <tr>
        <td>
          <span>
            <xsl:text>Существующий\ образующийся участок</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="DictBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="@exist"/>
            <xsl:with-param name="noc" select="true"/>
            <xsl:with-param name="dic">
              <xsl:call-template name="sExist"/>
            </xsl:with-param>
          </xsl:call-template>
        </td>
        <td>
          <span>
            <xsl:text>Тип участка (код)</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="DictBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="@Name"/>
            <xsl:with-param name="dic">
              <xsl:call-template name="dParcels"/>
            </xsl:with-param>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:if>
    <xsl:if test="CadastralNumber!='' or Designation!=''">
      <tr>
        <td>
          <span>
            <xsl:text>Кадастровый номер</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="CadastralNumber"/>
          </xsl:call-template>
        </td>
        <td>
          <span>
            <xsl:text>Обозначение на плане</xsl:text>
          </span>
        </td>
        <td colspan="3">
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="Designation"/>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:if>
    <xsl:if test="Obj_Kind!=''">
      <tr>
        <td>
          <span>
            <xsl:text>Тип объекта (код)</xsl:text>
          </span>
        </td>
        <td colspan="3">
          <xsl:call-template name="DictBox">
            <xsl:with-param name="siz" select="75"/>
            <xsl:with-param name="val" select="Obj_Kind"/>
            <xsl:with-param name="dic">
              <xsl:choose>
                <xsl:when test="$DocumentVersion='Request11' or $DocumentVersion='Request12'">
                  <xsl:call-template name="dRealty"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:call-template name="dRealty14"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:with-param>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:if>
    <xsl:if test="@temp_id!='' and count(../../../Object/Parcels/Parcel)>1">
      <tr>
        <td colspan="2">
          <span>
            <xsl:text>Идентификатор объекта </xsl:text>
            <nobr>
              <xsl:text>(в файле)</xsl:text>
            </nobr>
          </span>
        </td>
        <td colspan="2">
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="50"/>
            <xsl:with-param name="val" select="@temp_id"/>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:if>
    <xsl:if test="Inventory!='' or Letter!=''">
      <tr>
        <td>
          <span>
            <xsl:text>Номер межевого дела</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="Inventory"/>
          </xsl:call-template>
        </td>
        <td>
          <span>
            <xsl:text>Литера на плане</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="Letter"/>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:if>

    <xsl:for-each select="Location">
      <tr>
        <td colspan="4">
          <span style="font-weight:bold">
            <xsl:text>Местоположение</xsl:text>
          </span>
        </td>
      </tr>
      <tr>
        <td colspan="4">
          <xsl:call-template name="Location">
            <xsl:with-param name="vis" select="'unvis'"/>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:for-each>
    <xsl:for-each select="AppliedFiles/AppliedFile">
      <xsl:call-template name="AppliedFile">
        <xsl:with-param name="pos" select="$pos"/>
        <xsl:with-param name="part" select="$part"/>
        <xsl:with-param name="path" select="$path"/>
      </xsl:call-template>
    </xsl:for-each>
    <xsl:for-each select="SubParcels/SubParcel">
      <tr>
        <td colspan="4">
          <span style="font-weight:bold">
            <xsl:text>Часть земельного участка</xsl:text>
          </span>
        </td>
      </tr>
      <tr>
        <td>
          <span>
            <xsl:text>Порядковый номер</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="@Ord_Num"/>
          </xsl:call-template>
        </td>
        <td>
          <span>
            <xsl:text>Обозначение на плане</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="@Designation"/>
          </xsl:call-template>
        </td>
      </tr>
      <xsl:for-each select="AppliedFiles/AppliedFile">

        <xsl:call-template name="AppliedFile">
          <xsl:with-param name="pos" select="$pos"/>
          <xsl:with-param name="part" select="$part"/>
          <xsl:with-param name="path" select="$path"/>
        </xsl:call-template>
      </xsl:for-each>
    </xsl:for-each>

  </xsl:template>

  <xsl:template name="Realty_Object">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:param name="path"/>
    <xsl:if test="@exist!=''">
      <tr>
        <td>
          <span>
            <xsl:text>Существующий\образующийся объект</xsl:text>
          </span>
        </td>
        <td colspan="3">
          <xsl:call-template name="DictBox">
            <xsl:with-param name="siz" select="75"/>
            <xsl:with-param name="val" select="@exist"/>
            <xsl:with-param name="noc" select="true"/>
            <xsl:with-param name="dic">
              <xsl:call-template name="sExist"/>
            </xsl:with-param>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:if>

    <xsl:if test="Register/Name!=''">
      <tr>
        <td>
          <span>
            <xsl:text>Наименование</xsl:text>
          </span>
        </td>
        <td colspan="3">
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="75"/>
            <xsl:with-param name="val" select="Register/Name"/>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:if>
    <xsl:if test="Obj_Kind!=''">
      <tr>
        <td >
          <span>
            <xsl:text>Тип объекта (код)</xsl:text>
          </span>
        </td>
        <td colspan="3">
          <xsl:call-template name="DictBox">
            <xsl:with-param name="siz" select="75"/>
            <xsl:with-param name="val" select="Obj_Kind"/>
            <xsl:with-param name="dic">
              <xsl:choose>
                <xsl:when test="$DocumentVersion='Request11' or $DocumentVersion='Request12'">
                  <xsl:call-template name="dRealty"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:call-template name="dRealty14"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:with-param>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:if>
    <xsl:if test="Register/Assignation_Code!=''">
      <tr>
        <td>
          <span>
            <xsl:text>Назначение объекта (код)</xsl:text>
          </span>
        </td>
        <td colspan="3">
          <xsl:call-template name="DictBox">
            <xsl:with-param name="siz" select="75"/>
            <xsl:with-param name="val" select="Register/Assignation_Code"/>
            <xsl:with-param name="dic">
              <xsl:call-template name="dASS"/>
            </xsl:with-param>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:if>
    <xsl:if test="Register/Number_Register/CadastralNumber!='' or Register/Number_Register/Inventory!=''">
      <tr>
        <td>
          <span>
            <xsl:text>Кадастровый номер</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="Register/Number_Register/CadastralNumber"/>
          </xsl:call-template>
        </td>
        <td>
          <span>
            <xsl:text>Инвентарный номер</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="Register/Number_Register/Inventory"/>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:if>
    <xsl:if test="Register/Number_Register/ConditionalCadastralNumber!='' or Register/Number_Register/Reg_Num!=''">
      <tr>
        <td>
          <span>
            <xsl:text>Условный кадастровый номер</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="Register/Number_Register/ConditionalCadastralNumber"/>
          </xsl:call-template>
        </td>
        <td>
          <span>
            <xsl:text>Реестровый номер</xsl:text>
          </span>
        </td>
        <td>
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="Register/Number_Register/Reg_Num"/>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:if>
    <xsl:if test="@GUID!=''">
      <tr>
        <td>
          <span>
            <xsl:text>Идентификатор объекта </xsl:text>
          </span>
        </td>
        <td colspan="3">
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="75"/>
            <xsl:with-param name="val" select="@GUID"/>
          </xsl:call-template>
        </td>
        <!--td>
          <span>
            <xsl:text>Идентификатор объекта </xsl:text>
            <nobr>
              <xsl:text>(в файле)</xsl:text>
            </nobr>
          </span>
        </td>
        <td>
          <xsl:call-template name="TextBox">
            <xsl:with-param name="siz" select="25"/>
            <xsl:with-param name="val" select="@temp_id"/>
          </xsl:call-template>
        </td-->
      </tr>
    </xsl:if>
    <xsl:for-each select="Location">
      <tr>
        <td colspan="4">
          <span style="font-weight:bold">
            <xsl:text>Местоположение</xsl:text>
          </span>
        </td>
      </tr>
      <tr>
        <td colspan="4">
          <xsl:call-template name="Location">
            <xsl:with-param name="vis" select="'unvis'"/>
          </xsl:call-template>
        </td>
      </tr>
    </xsl:for-each>
    <xsl:for-each select="AppliedFiles/AppliedFile">
      <xsl:call-template name="AppliedFile">
        <xsl:with-param name="pos" select="$pos"/>
        <xsl:with-param name="part" select="$part"/>
        <xsl:with-param name="path" select="$path"/>
      </xsl:call-template>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="Block">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:param name="path"/>
    <tr>
      <td>
        <span>
          <xsl:text>Кадастровый номер</xsl:text>
        </span>
      </td>
      <td colspan="3">
        <xsl:call-template name="TextBox">
          <xsl:with-param name="siz" select="75"/>
          <xsl:with-param name="val" select="CadastralNumber"/>
        </xsl:call-template>
      </td>
    </tr>
    <xsl:for-each select="AppliedFiles/AppliedFile">
      <xsl:call-template name="AppliedFile">
        <xsl:with-param name="pos" select="$pos"/>
        <xsl:with-param name="part" select="$part"/>
        <xsl:with-param name="path" select="$path"/>
      </xsl:call-template>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="AppliedFile">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:param name="path"/>
    <tr>
      <td>
        <span>
          <xsl:text>Тип файла (код)</xsl:text>
        </span>
      </td>
      <td colspan="3">
        <xsl:call-template name="DictBox">
          <xsl:with-param name="siz" select="75"/>
          <xsl:with-param name="val" select="@type"/>
          <xsl:with-param name="dic">
            <xsl:call-template name="dApplied_file_type"/>
          </xsl:with-param>
        </xsl:call-template>
      </td>
    </tr>
    <!--xsl:choose>
      <xsl:when test="$part='!Print!'">
        <xsl:call-template name="PictureInsert">
          <xsl:with-param name="path" select="$path"/>
        </xsl:call-template>
      </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="ImageRef">
            <xsl:with-param name="part" select="$part"/>
            <xsl:with-param name="type" select="$ttt"/>
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="pos0" select="$ppp"/>
            <xsl:with-param name="pos1" select="$ppp"/>
            <xsl:with-param name="pos2" select="$ppp"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose-->
    <tr>
      <td>
        <span>
          <xsl:text>Имя файла</xsl:text>
        </span>
      </td>
      <td colspan="3">
        <xsl:call-template name="TextBox">
          <xsl:with-param name="siz" select="75"/>
          <xsl:with-param name="val" select="@name"/>
        </xsl:call-template>
      </td>
    </tr>
  </xsl:template>

  <xsl:template name="Request">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:for-each select="//Request_GZK_Realty">
      <xsl:if test="$pos = position()">
        <p/>
        <table align="center">
          <xsl:attribute name="width">
            <xsl:value-of select="$TableWidth"/>
          </xsl:attribute>
          <xsl:call-template name="RequestMenu">
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="part" select="$part"/>
          </xsl:call-template>
        </table>
        <p align="center">
          <span style="font-weight:bold">
            <xsl:value-of select="$pos"/>
            <xsl:text>. ЗАЯВЛЕНИЕ</xsl:text>
          </span>
        </p>
        <table align="center" cellspacing="0" cellpadding="2" border="1" bgcolor="#eeeeee">
          <xsl:attribute name="width">
            <xsl:value-of select="$TableWidth"/>
          </xsl:attribute>
          <xsl:call-template name="RequestWork">
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="part" select="$part"/>
          </xsl:call-template>
        </table>
      </xsl:if>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="ItemRequest">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:param name="cpart"/>
    <xsl:param name="npart"/>
    <xsl:text> </xsl:text>
    <xsl:choose>
      <xsl:when test="$part = $cpart">
        <span style="font-weight:bold">
          <nobr>
            <xsl:value-of select="$npart"/>
          </nobr>
        </span>
      </xsl:when>
      <xsl:otherwise>
        <a href="#">
          <xsl:attribute name="onclick">
            <xsl:text>DoXslt("</xsl:text>
            <xsl:value-of select="$cpart"/>
            <xsl:text>",</xsl:text>
            <xsl:value-of select="$pos"/>
            <xsl:text>)</xsl:text>
          </xsl:attribute>
          <span>
            <nobr>
              <xsl:value-of select="$npart"/>
            </nobr>
          </span>
        </a>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="RequestMenu">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <tr>
      <td align="center">
        <a href="#" onclick='DoXslt("Main",0)'>
          <span>
            <xsl:text>Главная</xsl:text>
          </span>
        </a>
        <xsl:if test="Title">
          <xsl:call-template name="ItemRequest">
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="part" select="$part"/>
            <xsl:with-param name="cpart" select="'Title'"/>
            <xsl:with-param name="npart" select="'Титул документа'"/>
          </xsl:call-template>
        </xsl:if>
        <xsl:if test="Declarants">
          <xsl:call-template name="ItemRequest">
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="part" select="$part"/>
            <xsl:with-param name="cpart" select="'Declarants'"/>
            <xsl:with-param name="npart" select="'Заявители'"/>
          </xsl:call-template>
        </xsl:if>
        <xsl:if test="Agents">
          <xsl:call-template name="ItemRequest">
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="part" select="$part"/>
            <xsl:with-param name="cpart" select="'Agents'"/>
            <xsl:with-param name="npart" select="'Доверенные лица'"/>
          </xsl:call-template>
        </xsl:if>
        <xsl:if test="Object">
          <xsl:call-template name="ItemRequest">
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="part" select="$part"/>
            <xsl:with-param name="cpart" select="'Object'"/>
            <xsl:with-param name="npart" select="'Объекты заявления'"/>
          </xsl:call-template>
        </xsl:if>
        <xsl:if test="Applied_Documents and not(count(Applied_Documents/Applied_Document)=1 and Applied_Documents/Applied_Document/No_Type_Doc='000000' and Applied_Documents/Applied_Document/Number='' and Applied_Documents/Applied_Document/Kind = '999' and Applied_Documents/Applied_Document/Quantity/@Original='0')">
          <xsl:call-template name="ItemRequest">
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="part" select="$part"/>
            <xsl:with-param name="cpart" select="'Applied_Documents'"/>
            <xsl:with-param name="npart" select="'Приложенные документы'"/>
          </xsl:call-template>
        </xsl:if>
        <xsl:if test="Payment_Documents">
          <xsl:call-template name="ItemRequest">
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="part" select="$part"/>
            <xsl:with-param name="cpart" select="'Payment_Documents'"/>
            <xsl:with-param name="npart" select="'Платежные документы'"/>
          </xsl:call-template>
        </xsl:if>
        <xsl:if test="Request_Documents">
          <xsl:call-template name="ItemRequest">
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="part" select="$part"/>
            <xsl:with-param name="cpart" select="'Request_Documents'"/>
            <xsl:with-param name="npart" select="'Запрашиваемые документы'"/>
          </xsl:call-template>
        </xsl:if>
        <xsl:if test="Out_Documents">
          <xsl:call-template name="ItemRequest">
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="part" select="$part"/>
            <xsl:with-param name="cpart" select="'Out_Documents'"/>
            <xsl:with-param name="npart" select="'Выданные документы'"/>
          </xsl:call-template>
        </xsl:if>
        <!--xsl:if test="Current_Changes">
          <xsl:call-template name="ItemRequest">
            <xsl:with-param name="pos" select="$pos"/>
            <xsl:with-param name="part" select="$part"/>
            <xsl:with-param name="cpart" select="'Current_Changes'"/>
            <xsl:with-param name="npart" select="'Список изменений'"/>
          </xsl:call-template>
        </xsl:if-->
      </td>
    </tr>
  </xsl:template>

  <xsl:template name="RequestWork">
    <xsl:param name="pos"/>
    <xsl:param name="part"/>
    <xsl:choose>
      <xsl:when test="$part='Title'">
        <xsl:apply-templates select="Title"/>
      </xsl:when>
      <xsl:when test="$part='Declarants'">
        <xsl:apply-templates select="Declarants">
          <xsl:with-param name="pos" select="$pos"/>
          <xsl:with-param name="part" select="$part"/>
        </xsl:apply-templates>
      </xsl:when>
      <xsl:when test="$part='Agents'">
        <xsl:apply-templates select="Agents">
          <xsl:with-param name="pos" select="$pos"/>
          <xsl:with-param name="part" select="$part"/>
        </xsl:apply-templates>
      </xsl:when>
      <xsl:when test="$part='Object'">
        <xsl:apply-templates select="Object">
          <xsl:with-param name="pos" select="$pos"/>
          <xsl:with-param name="part" select="$part"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="Current_Changes"/>
        <xsl:apply-templates select="Information_CPTs"/>
      </xsl:when>
      <xsl:when test="$part='Applied_Documents'">
        <xsl:apply-templates select="Applied_Documents">
          <xsl:with-param name="pos" select="$pos"/>
          <xsl:with-param name="part" select="$part"/>
        </xsl:apply-templates>
      </xsl:when>
      <xsl:when test="$part='Payment_Documents'">
        <xsl:apply-templates select="Payment_Documents">
          <xsl:with-param name="pos" select="$pos"/>
          <xsl:with-param name="part" select="$part"/>
        </xsl:apply-templates>
      </xsl:when>
      <xsl:when test="$part='Request_Documents'">
        <xsl:apply-templates select="Request_Documents"/>
      </xsl:when>
      <xsl:when test="$part='Out_Documents'">
        <xsl:apply-templates select="Out_Documents">
          <xsl:with-param name="pos" select="$pos"/>
          <xsl:with-param name="part" select="$part"/>
        </xsl:apply-templates>
      </xsl:when>
      <!--xsl:when test="$part='Current_Changes'">
        <xsl:apply-templates select="Current_Changes"/>
      </xsl:when-->
    </xsl:choose>
  </xsl:template>

  <xsl:template name="Print">
    <xsl:param name="pos"/>
    <xsl:param name="path"/>
    <xsl:param name="codeout"/>
    <xsl:variable name="part" select="'!Print!'"/>
    <table cellspacing="0" cellpadding="2" border="1" bgcolor="#eeeeee">
      <xsl:attribute name="width">
        <xsl:value-of select="$TableWidth"/>
      </xsl:attribute>
      <tr>
        <td>
          <span style="font-weight:bold">
            <xsl:text>Заявление </xsl:text>
            <xsl:value-of select="$codeout"/>
          </span>
        </td>
      </tr>

      <xsl:apply-templates select="Requests_GZK_Realty/Request_GZK_Realty[position()=$pos]/Title"/>

      <xsl:apply-templates select="Requests_GZK_Realty/Request_GZK_Realty[position()=$pos]/Declarants">
        <xsl:with-param name="pos" select="$pos"/>
        <xsl:with-param name="part" select="$part"/>
        <xsl:with-param name="path" select="$path"/>
      </xsl:apply-templates>

      <xsl:apply-templates select="Requests_GZK_Realty/Request_GZK_Realty[position()=$pos]/Agents">
        <xsl:with-param name="pos" select="$pos"/>
        <xsl:with-param name="part" select="$part"/>
        <xsl:with-param name="path" select="$path"/>
      </xsl:apply-templates>

      <xsl:apply-templates select="Requests_GZK_Realty/Request_GZK_Realty[position()=$pos]/Object">
        <xsl:with-param name="pos" select="$pos"/>
        <xsl:with-param name="part" select="$part"/>
        <xsl:with-param name="path" select="$path"/>
      </xsl:apply-templates>
      <xsl:apply-templates select="Requests_GZK_Realty/Request_GZK_Realty[position()=$pos]/Current_Changes"/>
      <xsl:apply-templates select="Requests_GZK_Realty/Request_GZK_Realty[position()=$pos]/Information_CPTs"/>
      <xsl:apply-templates select="Requests_GZK_Realty/Request_GZK_Realty[position()=$pos]/Applied_Documents">
        <xsl:with-param name="pos" select="$pos"/>
        <xsl:with-param name="part" select="$part"/>
        <xsl:with-param name="path" select="$path"/>
      </xsl:apply-templates>

      <xsl:apply-templates select="Requests_GZK_Realty/Request_GZK_Realty[position()=$pos]/Payment_Documents">
        <xsl:with-param name="pos" select="$pos"/>
        <xsl:with-param name="part" select="$part"/>
        <xsl:with-param name="path" select="$path"/>
      </xsl:apply-templates>

      <xsl:apply-templates select="Requests_GZK_Realty/Request_GZK_Realty[position()=$pos]/Request_Documents"/>

      <xsl:apply-templates select="Requests_GZK_Realty/Request_GZK_Realty[position()=$pos]/Out_Documents">
        <xsl:with-param name="pos" select="$pos"/>
        <xsl:with-param name="part" select="$part"/>
        <xsl:with-param name="path" select="$path"/>
      </xsl:apply-templates>


    </table>
  </xsl:template>

  <xsl:template name="Main_Request">
    <tr>
      <td>
        <table style="width:100%">
          <xsl:call-template name="Table4"/>
          <tr>
            <td>
              <span>
                <xsl:text>Наименование заявления</xsl:text>
              </span>
            </td>
            <td colspan="3">
              <xsl:call-template name="TextBox">
                <xsl:with-param name="siz" select="75"/>
                <xsl:with-param name="val" select="Title/Rubric/Name"/>
              </xsl:call-template>
            </td>
          </tr>
          <tr>
            <td>
              <span>
                <xsl:text>Код заявления</xsl:text>
              </span>
            </td>
            <td colspan="3">
              <xsl:call-template name="DictBox">
                <xsl:with-param name="siz" select="75"/>
                <xsl:with-param name="val" select="Title/Rubric/Code"/>
                <xsl:with-param name="dic">
                  <xsl:call-template name="dRequest_Type"/>
                  <xsl:call-template name="dAllDocuments"/>
                </xsl:with-param>
              </xsl:call-template>
            </td>
          </tr>
          <xsl:for-each select="Declarants/Declarant">
            <tr>
              <td>
                <span>
                  <xsl:text>Заявитель - </xsl:text>
                  <xsl:choose>
                    <xsl:when test="Person">
                      <xsl:text>физ.лицо</xsl:text>
                    </xsl:when>
                    <xsl:when test="Organization">
                      <xsl:text>организация</xsl:text>
                    </xsl:when>
                  </xsl:choose>
                </span>
              </td>
              <td colspan="3">
                <xsl:choose>
                  <xsl:when test="Person">
                    <xsl:variable name="t2">
                      <xsl:value-of select="Person/FIO/Surname"/>
                      <xsl:text> </xsl:text>
                      <xsl:value-of select="Person/FIO/First"/>
                      <xsl:text> </xsl:text>
                      <xsl:value-of select="Person/FIO/Patronymic"/>
                    </xsl:variable>
                    <xsl:call-template name="TextBox">
                      <xsl:with-param name="siz" select="75"/>
                      <xsl:with-param name="val" select="$t2"/>
                    </xsl:call-template>
                  </xsl:when>
                  <xsl:when test="Organization">
                    <xsl:call-template name="TextBox">
                      <xsl:with-param name="siz" select="75"/>
                      <xsl:with-param name="val" select="Organization/Name"/>
                    </xsl:call-template>
                  </xsl:when>
                </xsl:choose>
              </td>
            </tr>
          </xsl:for-each>
        </table>
      </td>
    </tr>
    <xsl:for-each select="//Realty_Object">
      <tr>
        <td >
          <span style="font-weight:bold">
            <xsl:text>Объект (недвижимость)</xsl:text>
          </span>
        </td>
      </tr>
      <tr>
        <td>
          <table style="width:100%">
            <xsl:call-template name="Table4"/>
            <tr>
              <td>
                <span>
                  <xsl:text>Наименование объекта</xsl:text>
                </span>
              </td>
              <td colspan="3">
                <xsl:call-template name="TextBox">
                  <xsl:with-param name="siz" select="75"/>
                  <xsl:with-param name="val" select="Register/Name"/>
                </xsl:call-template>
              </td>
            </tr>
            <tr>
              <td>
                <span>
                  <xsl:text>Тип объекта (код)</xsl:text>
                </span>
              </td>
              <td colspan="3">
                <xsl:call-template name="DictBox">
                  <xsl:with-param name="siz" select="75"/>
                  <xsl:with-param name="val" select="Obj_Kind"/>
                  <xsl:with-param name="dic">
                    <xsl:choose>
                      <xsl:when test="$DocumentVersion='Request11' or $DocumentVersion='Request12'">
                        <xsl:call-template name="dRealty"/>
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:call-template name="dRealty14"/>
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:with-param>
                </xsl:call-template>
              </td>
            </tr>
            <tr>
              <td>
                <span>
                  <xsl:text>Назначение объекта (код)</xsl:text>
                </span>
              </td>
              <td colspan="3">
                <xsl:call-template name="DictBox">
                  <xsl:with-param name="dic">
                    <xsl:call-template name="dASS"/>
                  </xsl:with-param>
                  <xsl:with-param name="siz" select="75"/>
                  <xsl:with-param name="val" select="Register/Assignation_Code"/>
                </xsl:call-template>
              </td>
            </tr>
            <tr>
              <td>
                <span>
                  <xsl:text>Кадастровый номер</xsl:text>
                </span>
              </td>
              <td>
                <xsl:call-template name="TextBox">
                  <xsl:with-param name="siz" select="25"/>
                  <xsl:with-param name="val" select="Register/Number_Register/CadastralNumber"/>
                </xsl:call-template>
              </td>
              <td>
                <span>
                  <xsl:text>Инвентарный номер</xsl:text>
                </span>
              </td>
              <td>
                <xsl:call-template name="TextBox">
                  <xsl:with-param name="siz" select="25"/>
                  <xsl:with-param name="val" select="Register/Number_Register/Inventory"/>
                </xsl:call-template>
              </td>
            </tr>
            <xsl:if test="@GUID!=''">
              <tr>
                <td>
                  <span>
                    <xsl:text>Идентификатор объекта </xsl:text>
                  </span>
                </td>
                <td colspan="3">
                  <xsl:call-template name="TextBox">
                    <xsl:with-param name="siz" select="75"/>
                    <xsl:with-param name="val" select="@GUID"/>
                  </xsl:call-template>
                </td>
              </tr>
            </xsl:if>
          </table>
        </td>
      </tr>

      <xsl:for-each select="Location">
        <tr>
          <td colspan="4">
            <span style="font-weight:bold">
              <xsl:text>Местоположение</xsl:text>
            </span>
          </td>
        </tr>
        <tr>
          <td colspan="4">
            <xsl:call-template name="Location"/>
          </td>
        </tr>
      </xsl:for-each>
    </xsl:for-each>
    <xsl:for-each select="//Parcel">
      <tr>
        <td >
          <span style="font-weight:bold">
            <xsl:text>Объект (</xsl:text>
            <xsl:choose>
              <xsl:when test="@exist='yes'">
                <xsl:text>существующий </xsl:text>
              </xsl:when>
              <xsl:otherwise>
                <xsl:text>образующийся </xsl:text>
              </xsl:otherwise>
            </xsl:choose>
            <xsl:text>земельный участок)</xsl:text>
          </span>
        </td>
      </tr>
      <tr>
        <td>
          <table style="width:100%">
            <xsl:call-template name="Table4"/>
            <!--tr>
              <td>
                <span>
                  <xsl:text>Тип объекта (код)</xsl:text>
                </span>
              </td>
              <td colspan="3">
                <xsl:call-template name="DictBox">
                  <xsl:with-param name="dic">
                    <xsl:choose>
                <xsl:when test="$DocumentVersion='Request11' or $DocumentVersion='Request12'">
                  <xsl:call-template name="dRealty"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:call-template name="dRealty14"/>
                </xsl:otherwise>
              </xsl:choose>
                  </xsl:with-param>
                  <xsl:with-param name="siz" select="75"/>
                  <xsl:with-param name="val" select="Obj_Kind"/>
                </xsl:call-template>
              </td>
            </tr-->
            <xsl:choose>
              <xsl:when test="@exist='yes'">
                <tr>
                  <td>
                    <span>
                      <xsl:text>Кадастровый номер</xsl:text>
                    </span>
                  </td>
                  <td colspan="3">
                    <xsl:call-template name="TextBox">
                      <xsl:with-param name="siz" select="75"/>
                      <xsl:with-param name="val" select="CadastralNumber"/>
                    </xsl:call-template>
                  </td>
                </tr>
              </xsl:when>
              <xsl:otherwise>
                <tr>
                  <td>
                    <span>
                      <xsl:text>Обозначение на плане</xsl:text>
                    </span>
                  </td>
                  <td colspan="3">
                    <xsl:call-template name="TextBox">
                      <xsl:with-param name="siz" select="75"/>
                      <xsl:with-param name="val" select="Designation"/>
                    </xsl:call-template>
                  </td>
                </tr>
              </xsl:otherwise>
            </xsl:choose>

          </table>
        </td>
      </tr>
      <xsl:for-each select="Location">
        <tr>
          <td colspan="4">
            <span style="font-weight:bold">
              <xsl:text>Местоположение</xsl:text>
            </span>
          </td>
        </tr>
        <tr>
          <td colspan="4">
            <xsl:call-template name="Location"/>
          </td>
        </tr>
      </xsl:for-each>
    </xsl:for-each>
    <xsl:for-each select="//Block">
      <tr>
        <td >
          <span style="font-weight:bold">
            <xsl:text>Объект (кадастровый квартал)</xsl:text>
          </span>
        </td>
      </tr>
      <tr>
        <td>
          <table style="width:100%">
            <xsl:call-template name="Table4"/>
            <tr>
              <td>
                <span>
                  <xsl:text>Кадастровый номер</xsl:text>
                </span>
              </td>
              <td colspan="3">
                <xsl:call-template name="TextBox">
                  <xsl:with-param name="siz" select="75"/>
                  <xsl:with-param name="val" select="CadastralNumber"/>
                </xsl:call-template>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </xsl:for-each>
    <xsl:if test="//Rubric/Reg_Folder!=''">
      <xsl:for-each select="//Rubric">
        <tr>
          <td>
            <table style="width:100%">
              <xsl:call-template name="Table4"/>
              <tr>
                <td>
                  <span>
                    <xsl:text>Номер исходного заявления в ОКУ</xsl:text>
                  </span>
                </td>
                <td colspan="3">
                  <xsl:call-template name="TextBox">
                    <xsl:with-param name="siz" select="75"/>
                    <xsl:with-param name="val" select="Reg_Folder"/>
                  </xsl:call-template>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </xsl:for-each>
    </xsl:if>
  </xsl:template>

  <xsl:template name="Main_Request_GZK_Realty">
    <p/>
    <table align="center" cellspacing="0" cellpadding="2" border="1" bgcolor="#eeeeee">
      <xsl:attribute name="width">
        <xsl:value-of select="$TableWidth"/>
      </xsl:attribute>
      <tr>
        <td align="center">
          <a href="#">
            <xsl:attribute name="onclick">
              <xsl:text>DoXslt("Title",</xsl:text>
              <xsl:value-of select="position()"/>
              <xsl:text>)</xsl:text>
            </xsl:attribute>
            <span style="font-weight:bold">
              <xsl:value-of select="position()"/>
              <xsl:text>. ЗАЯВЛЕНИЕ</xsl:text>
            </span>
          </a>
          <span>
            <xsl:text> (</xsl:text>
            <a href="#">
              <xsl:attribute name="onclick">
                <xsl:text>DoXsltPrint(</xsl:text>
                <xsl:value-of select="position()"/>
                <xsl:text>)</xsl:text>
              </xsl:attribute>
              <xsl:text>на одной странице</xsl:text>
            </a>
            <xsl:text>)</xsl:text>
          </span>
        </td>
      </tr>
      <xsl:call-template name="Main_Request"/>
    </table>
  </xsl:template>

  <xsl:template name="Main">
    <P align="center">
      <span style="font-weight:bold">
        <xsl:text>ЗАЯВЛЕНИЕ</xsl:text>
      </span>
    </P>
    <xsl:for-each select="//eDocument">
      <xsl:call-template name="Main_eDocument"/>
    </xsl:for-each>
    <xsl:for-each select="//Request_GZK_Realty">
      <xsl:call-template name="Main_Request_GZK_Realty"/>
    </xsl:for-each>
  </xsl:template>

  <xsl:variable name="Version" select="//Requests_GZK_Realty/eDocument/@Version"/>
</xsl:stylesheet>
