<?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/evtTabCargo/v02_04_01" targetNamespace="http://www.esocial.gov.br/schema/evt/evtTabCargo/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="evtTabCargo">
          <xs:annotation>
            <xs:documentation>Evento utilizado para inclusão, alteração e exclusão de registros na tabela de cargos.</xs:documentation>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="ideEvento" type="TIdeCadastro">
                <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="infoCargo">
                <xs:annotation>
                  <xs:documentation>Identificação da operação (inclusão, alteração ou exclusão) e das informações do cargo.</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                  <xs:sequence>
                    <xs:choice>
                      <xs:element name="inclusao">
                        <xs:annotation>
                          <xs:documentation>Inclusão de novas informações</xs:documentation>
                        </xs:annotation>
                        <xs:complexType>
                          <xs:sequence>
                            <xs:element name="ideCargo" type="TideCargo">
                              <xs:annotation>
                                <xs:documentation>Informações de identificação do cargo e validade das informações que estão sendo incluídas</xs:documentation>
                              </xs:annotation>
                            </xs:element>
                            <xs:element name="dadosCargo" type="TDadosCargo">
                              <xs:annotation>
                                <xs:documentation>Detalhamento das informações do cargo que está sendo incluído</xs:documentation>
                              </xs:annotation>
                            </xs:element>
                          </xs:sequence>
                        </xs:complexType>
                      </xs:element>
                      <xs:element name="alteracao">
                        <xs:annotation>
                          <xs:documentation>Alteração de informações já existentes</xs:documentation>
                        </xs:annotation>
                        <xs:complexType>
                          <xs:sequence>
                            <xs:element name="ideCargo" type="TideCargo">
                              <xs:annotation>
                                <xs:documentation>Grupo de informações de identificação do cargo, apresentando código e período de validade do cargo cujas informações serão alteradas pelos dados constantes neste evento.</xs:documentation>
                              </xs:annotation>
                            </xs:element>
                            <xs:element name="dadosCargo" type="TDadosCargo">
                              <xs:annotation>
                                <xs:documentation>Informações do cargo</xs:documentation>
                              </xs:annotation>
                            </xs:element>
                            <xs:element name="novaValidade" type="TPeriodoValidade" minOccurs="0">
                              <xs:annotation>
                                <xs:documentation>Informação preenchida exclusivamente em caso de alteração do período de validade das informações do cargo identificado em {ideCargo}, apresentando o novo período de validade.</xs:documentation>
                              </xs:annotation>
                            </xs:element>
                          </xs:sequence>
                        </xs:complexType>
                      </xs:element>
                      <xs:element name="exclusao">
                        <xs:annotation>
                          <xs:documentation>Exclusão de informações</xs:documentation>
                        </xs:annotation>
                        <xs:complexType>
                          <xs:sequence>
                            <xs:element name="ideCargo" type="TideCargo">
                              <xs:annotation>
                                <xs:documentation>Identificação do registro que será excluído</xs:documentation>
                              </xs:annotation>
                            </xs:element>
                          </xs:sequence>
                        </xs:complexType>
                      </xs:element>
                    </xs:choice>
                  </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="TIdeCadastro">
    <xs:annotation>
      <xs:documentation>Identificação de evento de cadastro/tabelas</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <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="TideCargo">
    <xs:annotation>
      <xs:documentation>Identificação do cargo (código) e do período de validade das informações</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="codCargo">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Código do Cargo</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="iniValid">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Início da validade (AAAA-MM)</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:pattern value="[2]{1}\d{3}-(1[0-2]|0[1-9])"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="fimValid" minOccurs="0">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Período final da validade, no formato (AAAA-MM)</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:pattern value="[2]{1}\d{3}-(1[0-2]|0[1-9])"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TDadosCargo">
    <xs:annotation>
      <xs:documentation>Informações do Cargo</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="nmCargo">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Nome do Cargo</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="100"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="codCBO">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>CBO</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:pattern value="\d{4,6}"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="cargoPublico" minOccurs="0">
        <xs:annotation>
          <xs:documentation>Detalhamento de informações exclusivas para Cargos e Empregos Públicos</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="acumCargo">
              <xs:simpleType>
                <xs:annotation>
                  <xs:documentation>Acumula cargo?</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:byte">
                  <xs:pattern value="\d"/>
                </xs:restriction>
              </xs:simpleType>
            </xs:element>
            <xs:element name="contagemEsp">
              <xs:simpleType>
                <xs:annotation>
                  <xs:documentation>Possibilidade de contagem de tempo especial</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:byte">
                  <xs:pattern value="\d"/>
                </xs:restriction>
              </xs:simpleType>
            </xs:element>
            <xs:element name="dedicExcl">
              <xs:simpleType>
                <xs:annotation>
                  <xs:documentation>Indicar se é cargo de dedicação exclusiva</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:string">
                  <xs:pattern value="[N|S]"/>
                </xs:restriction>
              </xs:simpleType>
            </xs:element>
            <xs:element name="leiCargo">
              <xs:annotation>
                <xs:documentation>Lei que criou/extinguiu/reestruturou o cargo</xs:documentation>
              </xs:annotation>
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="nrLei">
                    <xs:simpleType>
                      <xs:annotation>
                        <xs:documentation>Número da Lei</xs:documentation>
                      </xs:annotation>
                      <xs:restriction base="xs:string">
                        <xs:whiteSpace value="preserve"/>
                        <xs:minLength value="1"/>
                        <xs:maxLength value="12"/>
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>
                  <xs:element name="dtLei">
                    <xs:simpleType>
                      <xs:annotation>
                        <xs:documentation>Data da Lei</xs:documentation>
                      </xs:annotation>
                      <xs:restriction base="xs:date">
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>
                  <xs:element name="sitCargo">
                    <xs:simpleType>
                      <xs:annotation>
                        <xs:documentation>Situação cargo</xs:documentation>
                      </xs:annotation>
                      <xs:restriction base="xs:byte">
                        <xs:pattern value="\d"/>
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TPeriodoValidade">
    <xs:sequence>
      <xs:element name="iniValid">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Início da validade (AAAA-MM)</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:pattern value="[2]{1}\d{3}-(1[0-2]|0[1-9])"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="fimValid" minOccurs="0">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Período final da validade, no formato (AAAA-MM)</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:pattern value="[2]{1}\d{3}-(1[0-2]|0[1-9])"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>
