<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.esocial.gov.br/schema/evt/evtInsApo/v02_04_01" targetNamespace="http://www.esocial.gov.br/schema/evt/evtInsApo/v02_04_01" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd"/>
  <xs:element name="eSocial">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="evtInsApo">
          <xs:annotation>
            <xs:documentation>Insalubridade, periculosidade e aposentadoria especial</xs:documentation>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="ideEvento" type="TIdeEveTrab">
                <xs:annotation>
                  <xs:documentation>Informações de Identificação do Evento</xs:documentation>
                </xs:annotation>
              </xs:element>
              <xs:element name="ideEmpregador" type="TEmpregador">
                <xs:annotation>
                  <xs:documentation>Informações de identificação do empregador</xs:documentation>
                </xs:annotation>
              </xs:element>
              <xs:element name="ideVinculo" type="TIdeVincEstagCoop">
                <xs:annotation>
                  <xs:documentation>Informações de Identificação do Trabalhador e do Vínculo. Aplicar uma das seguintes regras, de acordo com a categoria do trabalhador.</xs:documentation>
                </xs:annotation>
              </xs:element>
              <xs:element name="insalPeric" minOccurs="0">
                <xs:annotation>
                  <xs:documentation>Informações sobre o ambiente de trabalho insalubre/periculoso.</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="iniInsalPeric" minOccurs="0">
                      <xs:annotation>
                        <xs:documentation>Condições do ambiente de trabalho insalubre/periculoso - Início</xs:documentation>
                      </xs:annotation>
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="dtIniCondicao">
                            <xs:simpleType>
                              <xs:annotation>
                                <xs:documentation>Data de Início da Condição</xs:documentation>
                              </xs:annotation>
                              <xs:restriction base="xs:date">
                              </xs:restriction>
                            </xs:simpleType>
                          </xs:element>
                          <xs:element name="infoAmb" type="TinfoAmbiente" maxOccurs="99">
                            <xs:annotation>
                              <xs:documentation>Detalhamento dos ambientes de trabalho em que o trabalhador desempenha atividades insalubres/periculosa.</xs:documentation>
                            </xs:annotation>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="altInsalPeric" minOccurs="0">
                      <xs:annotation>
                        <xs:documentation>Condições do ambiente de trabalho insalubre/periculoso - Alteração</xs:documentation>
                      </xs:annotation>
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="dtAltCondicao">
                            <xs:simpleType>
                              <xs:annotation>
                                <xs:documentation>Data de Alteração da Condição</xs:documentation>
                              </xs:annotation>
                              <xs:restriction base="xs:date">
                              </xs:restriction>
                            </xs:simpleType>
                          </xs:element>
                          <xs:element name="infoamb" type="TinfoAmbiente" maxOccurs="99">
                            <xs:annotation>
                              <xs:documentation>Informações sobre as condições de trabalho insalubre/periculoso.</xs:documentation>
                            </xs:annotation>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="fimInsalPeric" minOccurs="0">
                      <xs:annotation>
                        <xs:documentation>Condições do ambiente de trabalho insalubre/periculoso - Fim</xs:documentation>
                      </xs:annotation>
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="dtFimCondicao">
                            <xs:simpleType>
                              <xs:annotation>
                                <xs:documentation>Data Término da Condição Diferenciada</xs:documentation>
                              </xs:annotation>
                              <xs:restriction base="xs:date">
                              </xs:restriction>
                            </xs:simpleType>
                          </xs:element>
                          <xs:element name="infoAmb" maxOccurs="99">
                            <xs:annotation>
                              <xs:documentation>Detalha o ambiente de trabalho em que o trabalhador desempenha atividade insalubre/periculosa</xs:documentation>
                            </xs:annotation>
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="codAmb">
                                  <xs:simpleType>
                                    <xs:annotation>
                                      <xs:documentation>Código do Ambiente de Trabalho</xs:documentation>
                                    </xs:annotation>
                                    <xs:restriction base="xs:string">
                                      <xs:minLength value="1"/>
                                      <xs:maxLength value="30"/>
                                    </xs:restriction>
                                  </xs:simpleType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="aposentEsp" minOccurs="0">
                <xs:annotation>
                  <xs:documentation>Informações sobre o trabalho exercido em condições que ensejam a aposentadoria especial.</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="iniAposentEsp" minOccurs="0">
                      <xs:annotation>
                        <xs:documentation>Condições do ambiente de trabalho que ensejam aposentadoria especial - Início</xs:documentation>
                      </xs:annotation>
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="dtIniCondicao">
                            <xs:simpleType>
                              <xs:annotation>
                                <xs:documentation>Data de Início da Condição</xs:documentation>
                              </xs:annotation>
                              <xs:restriction base="xs:date">
                              </xs:restriction>
                            </xs:simpleType>
                          </xs:element>
                          <xs:element name="infoAmb" type="TinfoAmbiente" maxOccurs="99">
                            <xs:annotation>
                              <xs:documentation>Informações relativas ao ambiente de trabalho</xs:documentation>
                            </xs:annotation>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="altAposentEsp" minOccurs="0">
                      <xs:annotation>
                        <xs:documentation>Condições do ambiente de trabalho que ensejam aposentadoria especial - Alteração</xs:documentation>
                      </xs:annotation>
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="dtAltCondicao">
                            <xs:simpleType>
                              <xs:annotation>
                                <xs:documentation>Data de Alteração da Condição</xs:documentation>
                              </xs:annotation>
                              <xs:restriction base="xs:date">
                              </xs:restriction>
                            </xs:simpleType>
                          </xs:element>
                          <xs:element name="infoamb" type="TinfoAmbiente" maxOccurs="99">
                            <xs:annotation>
                              <xs:documentation>Informações relativas ao ambiente de trabalho</xs:documentation>
                            </xs:annotation>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="fimAposentEsp" minOccurs="0">
                      <xs:annotation>
                        <xs:documentation>Condições do ambiente de trabalho que ensejam aposentadoria especial - Término</xs:documentation>
                      </xs:annotation>
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="dtFimCondicao">
                            <xs:simpleType>
                              <xs:annotation>
                                <xs:documentation>Data Término da Condição Diferenciada</xs:documentation>
                              </xs:annotation>
                              <xs:restriction base="xs:date">
                              </xs:restriction>
                            </xs:simpleType>
                          </xs:element>
                          <xs:element name="infoAmb" maxOccurs="99">
                            <xs:annotation>
                              <xs:documentation>Informações relativas ao ambiente de trabalho</xs:documentation>
                            </xs:annotation>
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="codAmb">
                                  <xs:simpleType>
                                    <xs:annotation>
                                      <xs:documentation>Código do Ambiente de Trabalho</xs:documentation>
                                    </xs:annotation>
                                    <xs:restriction base="xs:string">
                                      <xs:minLength value="1"/>
                                      <xs:maxLength value="30"/>
                                    </xs:restriction>
                                  </xs:simpleType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="Id" type="xs:ID" use="required"/>
          </xs:complexType>
        </xs:element>
        <xs:element ref="ds:Signature"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:complexType name="TIdeEveTrab">
    <xs:annotation>
      <xs:documentation>Identificação do evento</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="indRetif">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Indicativo de Retificação</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:byte">
            <xs:pattern value="\d"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="nrRecibo" minOccurs="0">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Recibo arquivo a ser retificado</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="40"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="tpAmb">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Tipo de ambiente</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:byte">
            <xs:pattern value="\d"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="procEmi">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Processo de emissão do evento</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:byte">
            <xs:pattern value="\d"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="verProc">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Versão do processo de emissão do evento. </xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="20"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TEmpregador">
    <xs:sequence>
      <xs:element name="tpInsc">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Tipo de Inscrição, conforme tabela 5.</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:byte">
            <xs:pattern value="\d"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="nrInsc">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Número de Inscrição</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:pattern value="\d{8,15}"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TIdeVincEstagCoop">
    <xs:annotation>
      <xs:documentation>Informações do vínculo - empregados, estagiários e cooperados</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="cpfTrab">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>CPF do trabalhador</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:length value="11"/>
            <xs:pattern value="\d{11}"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="nisTrab" minOccurs="0">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>NIS</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:maxLength value="11"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="matricula" minOccurs="0">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Matricula</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="30"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TinfoAmbiente">
    <xs:annotation>
      <xs:documentation>Detalha o(s) Ambiente(s) de Trabalho em que o trabalhador desempenha atividades insalubres/periculosa.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="codAmb">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Código do Ambiente de Trabalho</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="30"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="fatRisco" maxOccurs="999">
        <xs:annotation>
          <xs:documentation>Fator de risco ao qual o trabalhador está exposto na atividade exercida no ambiente</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="codFatRis">
              <xs:simpleType>
                <xs:annotation>
                  <xs:documentation>Código do fator de risco</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:string">
                  <xs:minLength value="4"/>
                  <xs:maxLength value="10"/>
                </xs:restriction>
              </xs:simpleType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>
