﻿<?xml version="1.0" encoding="UTF-8"?>

<Regulations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Regulations\Regulation.xsd" Version="2.13.01202.0">

  <!-- Учет ЗУ -->
  <Regulation ExternalCheck="'{?Settings(ProgramS)?}'='Portal'" TypeReg="AO11" CodeReg="nwz" OIDMask=".+\.1\.3\.(1|3)(\.[01])?">
    <Pack CodePack="startA" OIDMask=".+\.1\.3\.(1|3)(\.[01])?" EditForms="MiniEditor\MiniEditor.xml">
      <Loads>
        <Load MinOcc="1" MaxOcc="3" Comment="версия 02">
          <LoadPacks>
            <PathUnPack PathMask="nwz_.*" />
          </LoadPacks>
          <File XMLMainElement="STD_MP" XMLVersion="//STD_MP/eDocument/@Version='02'" FileMask=".*\.xml" Xsd="Requests\V02_STD_MP\STD_MP.xsd" MinOcc="1" MaxOcc="1" CodeDoc="STD_MP02">
            <FormAddFiles PathName="{?GUID()?}">
              <AddFile FileType="binary" Optional="true" FileMask="\$Print\\MP\.mdc" CodeDoc="Print"/>
            </FormAddFiles>
            <LoadActions>
              <SetSessionID Value="{?GUID()?}"/>
              <SetFileName ExternalCheck="'{?Settings(ProgramR)?}'='Portal'" FileName="GKUZU_{?SessionID()?}.xml"/>
              <SetFileName ExternalCheck="'{?Settings(ProgramR)?}'='Registrator'" FileName="GKUZU_{?SessionID()?}!nwz.xml"/>
              <InsertNode NodeType="First" Node="//eDocument" NodeName="@GUID" InsertPosition="First"/>
              <Paste  ExternalCheck="'{?Settings(ProgramR)?}'='Portal'" NodeType="First" Node="//eDocument/@GUID" Value="{?SessionID()?}"/>
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Registrator'" NodeType="First" Node="//eDocument/@GUID" Value="{?SessionID()?}!nwz" />
            </LoadActions>
          </File>
          <File FileMask="RREQ_.*\.xml" XMLMainElement="Requests_GZK_Realty" XMLVersion="//Requests_GZK_Realty/eDocument/@Version='12'" Comment="версия 12" Xsd="Requests\V12_CR_ZC_REQ_Request\CR_ZC_REQ_Reqest.xsd" MinOcc="0" MaxOcc="1" CodeDoc="Requests_GZK_Realty12">
            <FormAddFiles PathName="{?GUID()?}">
              <AddFile FileType="binary" ValueNode="//Images/Image/@Name" CodeDoc="docum"/>
              <AddFile FileType="binary" ValueNode="//AppliedFiles/AppliedFile[@type!='01' and @type!='02']/@name" CodeDoc="docum"/>
              <AddFile FileType="binary" Optional="true" FileMask="\$Print\\Request\.mdc" CodeDoc="Print"/>
            </FormAddFiles>
            <LoadActions>
              <InsertNode NodeType="First" Node="//Title/Rubric" NodeName="GUID" InsertPosition="Before" NodeList="Method;Request_Text"/>
              <Paste NodeType="First" Node="//Title/Rubric/GUID" Value="{?SessionID()?}!nwz"/>
              <Paste NodeType="First" Node="//eDocument/@CodeType" Value="107"/>
              <Paste NodeType="First" Node="//Title/Rubric/Number" Value=""/>
              <DeleteNode NodeType="First" Node="//Title/Rubric/Book_Number"/>
              <DeleteNode NodeType="First" Node="//Title/Rubric/Reg_Folder"/>
              <Paste NodeType="First" Node="//Title/Executive/Login" Value=""/>
              <InsertTree NodeType="First" Node="//Request_GZK_Realty/Applied_Documents[count(Applied_Document[Kind='019'])=0]" InsertPosition="Last" InsertIfExist="true">
                <Applied_Document>
                  <No_Type_Doc>000000</No_Type_Doc>
                  <Number/>
                  <Kind>019</Kind>
                  <Quantity Original="1" Original_Sheet="1"/>
                </Applied_Document>
              </InsertTree>
              <InsertNode NodeType="First" Node="//Request_GZK_Realty/Applied_Documents/Applied_Document[Kind='019']" NodeName="AppliedFiles" InsertPosition="Last"/>
              <InsertTree NodeType="First" Node="//Request_GZK_Realty/Applied_Documents/Applied_Document[Kind='019']/AppliedFiles[count(AppliedFile[@type='02'])=0]" InsertPosition="Last" InsertIfExist="true">
                <AppliedFile type="02" name=""/>
              </InsertTree>
              <Paste NodeType="First" Node="//Request_GZK_Realty/Applied_Documents/Applied_Document[Kind='019']/AppliedFiles/AppliedFile/@name" Value="GKUZU_{?SessionID()?}!nwz.xml"/>
              <Paste NodeType="All" Node="//Request_Document[@Method_Accordance='03']/@Method_Accordance" Value="02"/>
            </LoadActions>
          </File>
          <File FileMask="(R?REQ)_.*\.xml" Put="{?Put(1,$1)?}" XMLMainElement="Requests_GZK_Realty" XMLVersion="//Requests_GZK_Realty/eDocument/@Version='14'" Comment="версия 14" Xsd="Requests\V14_CR_ZC_REQ_Request\CR_ZC_REQ_Reqest.xsd" MinOcc="0" MaxOcc="1" CodeDoc="Requests_GZK_Realty">
            <FormAddFiles PathName="{?GUID()?}">
              <AddFile FileType="binary" ValueNode="//Images/Image/@Name" CodeDoc="docum"/>
              <AddFile FileType="binary" ValueNode="//AppliedFiles/AppliedFile[@type!='01' and @type!='02']/@name" CodeDoc="docum"/>
              <AddFile FileType="binary" Optional="true" FileMask="\$Print\\Request\.mdc" CodeDoc="Print"/>
            </FormAddFiles>
            <LoadActions>
              <SetFileName ExternalCheck="'{?Settings(ProgramR)?}'='Portal'" FileName="req_{?SessionID()?}.xml"/>
              <SetFileName ExternalCheck="'{?Settings(ProgramR)?}'='Registrator'" FileName="RREQ_{?SessionID()?}!nwz.xml"/>
              <InsertNode NodeType="First" Node="//Title/Rubric" NodeName="GUID" InsertPosition="Before" NodeList="Method;Request_Text"/>
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Portal'" NodeType="First" Node="//Title/Rubric/GUID" Value="{?SessionID()?}"/>
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Registrator'" NodeType="First" Node="//Title/Rubric/GUID" Value="{?SessionID()?}!nwz"/>
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Portal'" NodeType="First" Node="//eDocument/@CodeType" Value="112" />
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Registrator'" NodeType="First" Node="//eDocument/@CodeType" Value="107"/>
              <Paste NodeType="First" Node="//Title/Rubric/Number" Value=""/>
              <DeleteNode NodeType="First" Node="//Title/Rubric/Book_Number"/>
              <DeleteNode NodeType="First" Node="//Title/Rubric/Reg_Folder"/>
              <Paste NodeType="First" Node="//Title/Executive/Login" Value=""/>
              <InsertTree NodeType="First" Node="//Request_GZK_Realty/Applied_Documents[count(Applied_Document[Code_Document='558203000000'])=0]" InsertPosition="Last" InsertIfExist="true">
                <Applied_Document>
                  <Code_Document>558203000000</Code_Document>
                  <Number>1</Number>
                  <Quantity Original="1" Original_Sheet="1"/>
                </Applied_Document>
              </InsertTree>
              <InsertNode NodeType="First" Node="//Request_GZK_Realty/Applied_Documents/Applied_Document[Code_Document='558203000000']" NodeName="AppliedFiles" InsertPosition="Last"/>
              <InsertTree NodeType="First" Node="//Request_GZK_Realty/Applied_Documents/Applied_Document[Code_Document='558203000000']/AppliedFiles[count(AppliedFile[@type='02'])=0]" InsertPosition="Last" InsertIfExist="true">
                <AppliedFile type="02" name=""/>
              </InsertTree>
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Portal'" NodeType="First" Node="//Request_GZK_Realty/Applied_Documents/Applied_Document[Code_Document='558203000000']/AppliedFiles/AppliedFile/@name" Value="GKUZU_{?SessionID()?}.xml"/>
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Registrator'" NodeType="First" Node="//Request_GZK_Realty/Applied_Documents/Applied_Document[Code_Document='558203000000']/AppliedFiles/AppliedFile/@name" Value="GKUZU_{?SessionID()?}!nwz.xml"/>
            </LoadActions>
          </File>
          <File FileMask="(R?REQ)_.*\.xml" Put="{?Put(1,$1)?}" XMLMainElement="Requests_GZK_Realty" XMLVersion="//Requests_GZK_Realty/eDocument/@Version='15'" Comment="версия 15" Xsd="Requests\V15_CR_ZC_REQ_Request\CR_ZC_REQ_Reqest.xsd" MinOcc="0" MaxOcc="1" CodeDoc="Requests_GZK_Realty">
            <FormAddFiles PathName="{?GUID()?}">
              <AddFile FileType="binary" ValueNode="//Images/Image/@Name" CodeDoc="docum"/>
              <AddFile FileType="binary" ValueNode="//AppliedFiles/AppliedFile[@type!='01' and @type!='02']/@name" CodeDoc="docum"/>
              <AddFile FileType="binary" Optional="true" FileMask="\$Print\\Request\.mdc" CodeDoc="Print"/>
            </FormAddFiles>
            <LoadActions>
              <SetFileName ExternalCheck="'{?Settings(ProgramR)?}'='Portal'" FileName="req_{?SessionID()?}.xml"/>
              <SetFileName ExternalCheck="'{?Settings(ProgramR)?}'='Registrator'" FileName="RREQ_{?SessionID()?}!nwz.xml"/>
              <InsertNode NodeType="First" Node="//Title/Rubric" NodeName="GUID" InsertPosition="Before" NodeList="Method;Request_Text"/>
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Portal'" NodeType="First" Node="//Title/Rubric/GUID" Value="{?SessionID()?}" />
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Registrator'" NodeType="First" Node="//Title/Rubric/GUID" Value="{?SessionID()?}!nwz" />
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Portal'" NodeType="First" Node="//eDocument/@CodeType" Value="112" />
              <Paste  ExternalCheck="'{?Settings(ProgramR)?}'='Registrator'" NodeType="First" Node="//eDocument/@CodeType" Value="107"/>
              <Paste NodeType="First" Node="//Title/Rubric/Number" Value=""/>
              <DeleteNode NodeType="First" Node="//Title/Rubric/Book_Number"/>
              <DeleteNode NodeType="First" Node="//Title/Rubric/Reg_Folder"/>
              <Paste NodeType="First" Node="//Title/Executive/Login" Value=""/>
              <InsertTree NodeType="First" Node="//Request_GZK_Realty/Applied_Documents[count(Applied_Document[Code_Document='558203000000'])=0]" InsertPosition="Last" InsertIfExist="true">
                <Applied_Document>
                  <Code_Document>558203000000</Code_Document>
                  <Number>1</Number>
                  <Quantity Original="1" Original_Sheet="1"/>
                </Applied_Document>
              </InsertTree>
              <InsertNode NodeType="First" Node="//Request_GZK_Realty/Applied_Documents/Applied_Document[Code_Document='558203000000']" NodeName="AppliedFiles" InsertPosition="Last"/>
              <InsertTree NodeType="First" Node="//Request_GZK_Realty/Applied_Documents/Applied_Document[Code_Document='558203000000']/AppliedFiles[count(AppliedFile[@type='02'])=0]" InsertPosition="Last" InsertIfExist="true">
                <AppliedFile type="02" name=""/>
              </InsertTree>
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Portal'" NodeType="First" Node="//Request_GZK_Realty/Applied_Documents/Applied_Document[Code_Document='558203000000']/AppliedFiles/AppliedFile/@name" Value="GKUZU_{?SessionID()?}.xml"/>
              <Paste ExternalCheck="'{?Settings(ProgramR)?}'='Registrator'" NodeType="First" Node="//Request_GZK_Realty/Applied_Documents/Applied_Document[Code_Document='558203000000']/AppliedFiles/AppliedFile/@name" Value="GKUZU_{?SessionID()?}!nwz.xml"/>
            </LoadActions>
          </File>
          <File FileMask="\$Source\\MiniEditor\.xml" CodeDoc="docum" MinOcc="0" MaxOcc="1"/>
          <File FileMask="APP.*\.xml" XMLMainElement="Applied_Documents" MinOcc="0" MaxOcc="1" CodeDoc="Application">
            <FormAddFiles PathName=".">
              <AddFile FileType="binary" ValueNode="//Images/Image/@Name" CodeDoc="docum"/>
            </FormAddFiles>
          </File>
        </Load>
      </Loads>
      <Inside ExternalCheck="'{?Settings(ProgramS)?}'='Portal'" CountCheck="{?FilesCount(1)?}=1" Expect="Документ 'Межевой план'">
        <File XMLMainElement="STD_MP" XMLVersion="//STD_MP/eDocument/@Version='02'" FileMask="GKUZU_.*\.xml" Xslt="Regulations\STD_MP.xslt" Xsd="Requests\V02_STD_MP\STD_MP.xsd" CodeDoc="STD_MP02">
          <AddFiles PathMask=".*">
            <AddFile FileType="binary" Optional="true" FileMask=".+\\\$Print\\MP\.mdc" MinOcc="0" MaxOcc="1" CodeDoc="Print"/>
          </AddFiles>
          <AddChecks>
            <MaskCheck ExternalCheck="'{?Settings(InsideChecks)?}'='Yes'" NodeType="First" ValueNode="//STD_MP/eDocument/@CodeType" ValueMask="014" Error="В документе 'Межевой план' не правильно указан код обрабатывающей программы (@CodeType)" Expect="'014'"/>
            <TestCheck ExternalCheck="'{?Settings(InsideChecks)?}'='Yes'" NodeType="First" Node="//STD_MP" Test="count(.//NewParcel)>=1" Error="В документе 'Межевой план' должен быть описан хотя бы один образуемый ЗУ (NewParcel)."/>
            <TestCheck ExternalCheck="'{?Settings(InsideChecks)?}'='Yes'" NodeType="All" Node="//NewParcel" Test="@Method='{?Get(4)?}'" Error="В разделе 'Участок' указан способ образования ЗУ (@Method), не совпадающий с описанным в 'Заявлении': '{?Get(4)?}' (1 - Выдел, 2 - Раздел, 3 - Раздел единого землепользования, 4 - Перераспределение, 5 - Иной способ)."/>
            <TestCheck ExternalCheck="'{?Settings(InsideChecks)?}'='Yes'" NodeType="All" Node="//NewParcel" Test="@Definition!=''" Error="В разделе 'Участок' не указано обозначение на плане (@Definition)"/>
            <TestCheck ExternalCheck="'{?Settings(InsideChecks)?}'='Yes'" NodeType="All" Node="//NewParcel" Test="@Method='5' or count(.//Prev_CadastralNumbers)>=1" Error="В разделе 'Участок' не описаны кадастровые номера ЗУ, из которых образован данный ЗУ (Prev_CadastralNumbers)."/>
            <TestCheck ExternalCheck="'{?Settings(InsideChecks)?}'='Yes'" NodeType="All" Node="//Contour" Test="@Definition!='-'" Error="Не указано обозначение контура многоконтурного участка (Contour/@Definition)."/>
            <MaskCheck ExternalCheck="'{?Settings(InsideChecks)?}'='Yes'" NodeType="All" ValueNode="//NewParcel/SubParcel/@Number_PP" ValueMask="" Error="В разделе 'Часть участка' образуемого ЗУ указан порядковый номер (@Number_PP)" Expect="отсутствие значения"/>
            <TestCheck ExternalCheck="'{?Settings(InsideChecks)?}'='Yes'" NodeType="All" Node="//NewParcel/SubParcel" Test=".//@Definition!=''" Error="В разделе 'Часть участка' образуемого ЗУ не указано обозначение на плане (@Definition)."/>
            <TestCheck ExternalCheck="'{?Settings(InsideChecks)?}'='Yes'" NodeType="All" Node="//ChangeParcel/SubParcel" Test=".//@Definition!='' or .//@Number_PP!=''" Error="В разделе 'Часть участка' измененного ЗУ не указано ни обозначение на плане (@Definition), ни порядковый номер (@Number_PP)."/>
            <TestCheck ExternalCheck="'{?Settings(InsideChecks)?}'='Yes'" NodeType="All" Node="//SubParcel" Test="count(.//Entity_Spatial)>=1" Error="В разделе 'Часть участка' не описана пространственная составляющая (Entity_Spatial)."/>
            <TestCheck ExternalCheck="'{?Settings(InsideChecks)?}'='Yes'" NodeType="All" Node="//Area" Test="not(.//Area='0')" Error="В разделе 'Участок' или 'Часть участка' указана площадь, равная 0 (Area/Area = 0)."/>
          </AddChecks>
        </File>
        <File XMLMainElement="Applied_Documents" FileMask="APP.*\.xml" Xslt="Regulations\Applied_Documents.xslt" CodeDoc="Application">
          <AddFiles PathMask=".*">
            <AddFile ValueNode="//Images/Image/@Name" FileMask=".*" MinOcc="0" MaxOcc="*" CodeDoc="docum"/>
          </AddFiles>
        </File>
      </Inside>
      <!--Info>
        <File FileMask="R?REQ_(.*)\.xml" Put="{?Put(9,$1)?}">
          <Params>
            <Param Name="GUID" Letter="{?Get(9)?}"/>
            <Param Name="RouteOKATO" ValueNode="//Requests_GZK_Realty/eDocument/comment()" />
            <Param Name="CodeRequest" ValueNode="//Requests_GZK_Realty/Request_GZK_Realty/Title/Rubric/Code" />
          </Params>
          <Columns>
            <Column Caption="Кад. номер" Name="CadastralNumber" XPath="//Requests_GZK_Realty/Request_GZK_Realty/Object/Parcels/Parcel[@exist = 'yes']/CadastralNumber"/>
          </Columns>
        </File>
      </Info-->
      <Unloads>
        <Unload ExternalCheck="'{?Settings(Unload)?}'='Portal'" Code="mp" Name="Межевой план">
          <UnloadPacks>
            <PathPack PathName="mp_{?SessionID()?}"/>
          </UnloadPacks>
          <File FileMask="GKUZU_.*\.xml" FileName="GKUZU_{?SessionID()?}.xml" CodeDoc="STD_MP" MinOcc="1" MaxOcc="1"/>
          <File XMLMainElement="Applied_Documents" FileMask="APP.*\.xml" CodeDoc="Application" MinOcc="0" MaxOcc="1">
            <AddFiles PathMask=".*">
              <AddFile ValueNode="//Images/Image/@Name" FileMask=".*" MinOcc="0" MaxOcc="*" CodeDoc="docum"/>
            </AddFiles>
          </File>
        </Unload>
      </Unloads>
    </Pack>
  </Regulation>
</Regulations>
