<?xml version="1.0" encoding="windows-1251" ?>
<xsl:stylesheet version="1.0" 
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:pfr="http://ïô.ðô/ÅÔÑ-1/2022-09-22" 
                xmlns:ÅÔÑ="http://ïô.ðô/ÂÑ/ÅÔÑ/2022-09-22" 
                xmlns:ÓÒ2="http://ïô.ðô/ÓÒ/2017-08-21" 
                xmlns:ÂÑ2="http://ïô.ðô/ÂÑ/òèïû/2017-10-23" 
                xmlns:ÀÔ5="http://ïô.ðô/ÀÔ/2018-12-07">

<!-- Âûâîä â xml-ôàéë ñ WIN-êîäèðîâêîé -->
<xsl:output method="xml" version="1.0" encoding="windows-1251" />
<xsl:decimal-format decimal-separator="."/>
<xsl:param name = "ReestrSource" select = "'ReportParams'"/>

<!-- Êëþ÷ äëÿ ïåðèîäà: Ãîä+Êâàðòàë -->
<xsl:key name="KeyPeriod" match="InfoAboutCorr" use="concat(pfr:Ãîä,pfr:Êâàðòàë)"/>
<!-- Êëþ÷ äëÿ ïåðèîäà: Ãîä+Êâàðòàë (èç àòðèáóòîâ) -->
<xsl:key name="KeyPeriodA" match="pfr:ÐååñòðÏîÐàçäåëàì6_6" use="concat(pfr:Period/@Year,pfr:Period/@Cod)"/>

<!-- Âõîäíàÿ èíôîðìàöèÿ î ôàéëàõ ÏÔÐ ïðèâîäèòñÿ ê åäèíîìó ôîðìàòó è ñîõðàíÿåòñÿ â ïåðåìåííîé
     Reports --> 
<xsl:variable name="Reports">
   <xsl:element name="ReportList">
         <xsl:for-each select=".//Ôàéë">
               <xsl:element name="File">
                  <xsl:attribute name="FullName">
                     <xsl:value-of select="@ÏîëíîåÈìÿ"/>
                  </xsl:attribute>
                  <!--
                   <xsl:for-each select="document(@ÏîëíîåÈìÿ)/pfr:ÝÄÏÔÐ/pfr:ÅÔÑ-1">
                      <xsl:attribute name="Month">
                         <xsl:value-of select=".//pfr:Îò÷åòíûéÏåðèîä/pfr:Êâàðòàë"/>
                      </xsl:attribute>
                      <xsl:attribute name="Year">
                         <xsl:value-of select=".//pfr:Îò÷åòíûéÏåðèîä/pfr:Ãîä"/>
                      </xsl:attribute>
                      <xsl:attribute name="Type">
                         <xsl:value-of select=".//pfr:ÒèïÑâåäåíèé"/>
                      </xsl:attribute>
                   </xsl:for-each>
                   -->
                </xsl:element>
         </xsl:for-each>
   </xsl:element>
</xsl:variable>

<xsl:variable name="AllEfs1Stag">
   <xsl:for-each select="document(msxsl:node-set($Reports)//ReportList/File/@FullName)/pfr:ÝÄÏÔÐ//pfr:ÅÔÑ-1//pfr:ÑÇÂ//pfr:ÇË//pfr:ÑÇÂ-ÑÒÀÆ">
      <xsl:element name="Insured">
         <xsl:attribute name="SNILS">
            <xsl:value-of select="ancestor-or-self::*/ÓÒ2:ÑÍÈËÑ" />
         </xsl:attribute>
         <xsl:attribute name="F">
            <xsl:value-of select="ancestor-or-self::*/ÓÒ2:ÔÈÎ/ÓÒ2:Ôàìèëèÿ" />
         </xsl:attribute>
         <xsl:attribute name="I">
            <xsl:value-of select="ancestor-or-self::*/ÓÒ2:ÔÈÎ/ÓÒ2:Èìÿ" />
         </xsl:attribute>
         <xsl:attribute name="O">
            <xsl:value-of select="ancestor-or-self::*/ÓÒ2:ÔÈÎ/ÓÒ2:Îò÷åñòâî" />
         </xsl:attribute>
         <xsl:for-each select=".//pfr:ÑòàæåâûéÏåðèîä">
         <xsl:element name="Period">
           <xsl:attribute name="DBeg">
              <xsl:value-of select="./pfr:Ïåðèîä/ÓÒ2:Ñ"/>
           </xsl:attribute>
           <xsl:attribute name="DEnd">
              <xsl:value-of select="./pfr:Ïåðèîä/ÓÒ2:Ïî"/>
           </xsl:attribute>
           <!-- Òåððèòîðèàëüíûå óñëîâèÿ -->
           <xsl:if test=".//ÅÔÑ:ÒÓ">
              <xsl:attribute name="ÒÅÐÓÑË">
                 <xsl:value-of select=".//ÅÔÑ:ÒÓ/ÅÔÑ:Îñíîâàíèå"/>
              </xsl:attribute>
              <xsl:attribute name="ÒÅÐÐÊ">
                 <xsl:value-of select=".//ÅÔÑ:ÒÓ/ÅÔÑ:Êîýôôèöèåíò"/>
              </xsl:attribute>
              <xsl:attribute name="ÒÅÐÑÒÂÊ">
                 <xsl:value-of select=".//ÅÔÑ:ÒÓ/ÅÔÑ:ÄîëÿÑòàâêè"/>
              </xsl:attribute>
           </xsl:if>
           <!-- Èñ÷èñëÿåìûé ñòàæ -->
           <xsl:if test=".//ÅÔÑ:ÈÑ">
              <xsl:attribute name="ÎÑÍÒÐÑÒ">
                 <xsl:value-of select=".//ÅÔÑ:ÈÑ/ÅÔÑ:Îñíîâàíèå"/>
              </xsl:attribute>
         	  <xsl:choose>
                 <xsl:when test=".//ÅÔÑ:ÈÑ/ÂÑ2:ÂûðàáîòêàÊàëåíäàðíàÿ">
                    <xsl:attribute name="ÄÎÏ1ÑÒ">
                       <xsl:value-of select=".//ÅÔÑ:ÈÑ/ÂÑ2:ÂûðàáîòêàÊàëåíäàðíàÿ/ÂÑ2:ÂñåÌåñÿöû"/>
                    </xsl:attribute>
                    <xsl:attribute name="ÄÎÏ2ÑÒ">
                       <xsl:value-of select=".//ÅÔÑ:ÈÑ/ÂÑ2:ÂûðàáîòêàÊàëåíäàðíàÿ/ÂÑ2:ÂñåÄíè"/>
                    </xsl:attribute>
                 </xsl:when>
                 <xsl:when test=".//ÅÔÑ:ÈÑ/ÂÑ2:ÂûðàáîòêàÂ÷àñàõ">
                    <xsl:attribute name="ÄÎÏ1ÑÒ">
                       <xsl:value-of select=".//ÅÔÑ:ÈÑ/ÂÑ2:ÂûðàáîòêàÂ÷àñàõ/ÂÑ2:×àñû"/>
                    </xsl:attribute>
                    <xsl:attribute name="ÄÎÏ2ÑÒ">
                       <xsl:value-of select=".//ÅÔÑ:ÈÑ/ÂÑ2:ÂûðàáîòêàÂ÷àñàõ/ÂÑ2:Ìèíóòû"/>
                    </xsl:attribute>
                 </xsl:when>
              </xsl:choose>
           </xsl:if>
           <!-- Äîï.ñâåäåíèÿ -->
           <xsl:if test=".//ÅÔÑ:ÄîïÑâåäåíèÿÈÑ">
              <xsl:attribute name="ÄÎÏÒÐÑÒ">
                 <xsl:value-of select=".//ÅÔÑ:ÄîïÑâåäåíèÿÈÑ"/>
              </xsl:attribute>
           </xsl:if>
           <!-- ÎÓÒ -->
           <xsl:if test=".//ÅÔÑ:ÎÓÒ">
              <xsl:attribute name="ÎÑÎÁÓÑË">
                 <xsl:value-of select=".//ÅÔÑ:ÎÓÒ/ÅÔÑ:Êîä"/>
              </xsl:attribute>
              <xsl:attribute name="ÊÎÄÏÎÇ">
                 <xsl:value-of select=".//ÅÔÑ:ÎÓÒ/ÅÔÑ:ÏîçèöèÿÑïèñêà"/>
              </xsl:attribute>
           </xsl:if>
           <!-- Óñëîâèÿ äîñðî÷íîãî íàçíà÷åíèÿ ïåíñèè -->
           <xsl:if test=".//ÅÔÑ:ÂË">
              <xsl:attribute name="ÎÑÍÂÛÑË">
                 <xsl:value-of select=".//ÅÔÑ:ÂË/ÅÔÑ:Îñíîâàíèå"/>
              </xsl:attribute>
         	  <xsl:choose>
                 <xsl:when test=".//ÅÔÑ:ÂË/ÂÑ2:ÂûðàáîòêàÊàëåíäàðíàÿ">
                    <xsl:attribute name="ÄÎÏ1ÂÑ">
                       <xsl:value-of select=".//ÅÔÑ:ÂË/ÂÑ2:ÂûðàáîòêàÊàëåíäàðíàÿ/ÂÑ2:ÂñåÌåñÿöû"/>
                    </xsl:attribute>
                    <xsl:attribute name="ÄÎÏ2ÂÑ">
                       <xsl:value-of select=".//ÅÔÑ:ÂË/ÂÑ2:ÂûðàáîòêàÊàëåíäàðíàÿ/ÂÑ2:ÂñåÄíè"/>
                    </xsl:attribute>
                 </xsl:when>
                 <xsl:when test=".//ÅÔÑ:ÂË/ÂÑ2:ÂûðàáîòêàÂ÷àñàõ">
                    <xsl:attribute name="ÄÎÏ1ÂÑ">
                       <xsl:value-of select=".//ÅÔÑ:ÂË/ÂÑ2:ÂûðàáîòêàÂ÷àñàõ/ÂÑ2:×àñû"/>
                    </xsl:attribute>
                    <xsl:attribute name="ÄÎÏ2ÂÑ">
                       <xsl:value-of select=".//ÅÔÑ:ÂË/ÂÑ2:ÂûðàáîòêàÂ÷àñàõ/ÂÑ2:Ìèíóòû"/>
                    </xsl:attribute>
                 </xsl:when>
         	  </xsl:choose>
              <xsl:attribute name="ÄÎÏ3ÂÑ">
                 <xsl:value-of select=".//ÅÔÑ:ÂË/ÅÔÑ:ÄîëÿÑòàâêè"/>
              </xsl:attribute>
           </xsl:if>
         </xsl:element>
         </xsl:for-each>
      </xsl:element>
   </xsl:for-each>
</xsl:variable>

<xsl:template match="/">

<xsl:element name="InfoAboutTrStag">
<xsl:copy-of select="$AllEfs1Stag"/>
</xsl:element>

</xsl:template>

</xsl:stylesheet>