alek-sys / sublimetext_indentxml

Plugin for Sublime Text editor for reindenting XML and JSON files
MIT License
534 stars 135 forks source link

AttributeError: 'NoneType' object has no attribute 'replace' #65

Open GuilhermeMorais opened 9 years ago

GuilhermeMorais commented 9 years ago

Hi! I just tried to format this code below, but I receive an error. I just work with C# otherwise I will try to just place the solution in here. Thanks in advance. Maybe could the be accentuation?

Error msg:

    Traceback (most recent call last):
  File ".\sublime_plugin.py", line 362, in run_
  File ".\indentxml.py", line 44, in run
  File ".\indentxml.py", line 96, in indent
xml.parsers.expat.ExpatError: syntax error: line 1, column 0

text to Format:

<Requisicoes><Requisicao Chave="0c136047-ce55-4bd6-9aad-6b42fde53a3a" Uri="https://www.soc.com.br/WSSoc/services/LicencaMedicaWs" DataHora="10:30:41.796"><Envio><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none" /></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><consultarLoteLicencasMedicas xmlns="http://services.soc.age.com/"><consultaAfastamento xmlns=""><abonado>false</abonado><codigoEmpresaFuncionario>297044</codigoEmpresaFuncionario><dataFicha>17/09/2014</dataFicha><dataFimAfastamento>31/12/9999</dataFimAfastamento><dataInicioAfastamento>01/01/0001</dataInicioAfastamento><identificacaoVo>DADOS REMOVIDOS</identificacaoVo></consultaAfastamento></consultarLoteLicencasMedicas></s:Body></s:Envelope></Envio></Requisicao>
<Requisicao Chave="0c136047-ce55-4bd6-9aad-6b42fde53a3a" DataHora="10:30:42.270" TempoGasto="00:00:00.7448938"><Resposta><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" /><soap:Body><ns2:consultarLoteLicencasMedicasResponse xmlns:ns2="http://services.soc.age.com/"><Afastamento><abonado>true</abonado><acidenteTrajeto>false</acidenteTrajeto><cids>B00</cids><codigoEmpresaFuncionario>297044</codigoEmpresaFuncionario><codigoFuncionario>2</codigoFuncionario><codigoMotivoAfastamento>2</codigoMotivoAfastamento><codigoSequencialLicenca>53938015</codigoSequencialLicenca><cpfFuncionario>44218387729</cpfFuncionario><dataFicha>02/10/2015</dataFicha><dataFimAfastamento>19/10/2015</dataFimAfastamento><dataInicioAfastamento>02/10/2015</dataInicioAfastamento><descricaoMotivo>SUP. 15 DIAS.</descricaoMotivo><imprimirCid>false</imprimirCid><imprimirMotivo>false</imprimirMotivo><imprimirSolicitante>false</imprimirSolicitante><matriculaFuncionario>7778</matriculaFuncionario><tipoCid>DOENCA_RELACIONADOA_AO_TRABALHO</tipoCid><tipoDeAfastamento>2</tipoDeAfastamento></Afastamento><Afastamento><abonado>true</abonado><acidenteTrajeto>false</acidenteTrajeto><codigoEmpresaFuncionario>297044</codigoEmpresaFuncionario><codigoFuncionario>4</codigoFuncionario><codigoMotivoAfastamento>42</codigoMotivoAfastamento><codigoSequencialLicenca>53938296</codigoSequencialLicenca><cpfFuncionario>02374451747</cpfFuncionario><dataFicha>15/10/2015</dataFicha><dataFimAfastamento>15/10/2015</dataFimAfastamento><dataInicioAfastamento>15/10/2015</dataInicioAfastamento><descricaoMotivo>1 DIA</descricaoMotivo><imprimirCid>false</imprimirCid><imprimirMotivo>false</imprimirMotivo><imprimirSolicitante>false</imprimirSolicitante><matriculaFuncionario>7780</matriculaFuncionario><tipoDeAfastamento>7</tipoDeAfastamento></Afastamento><Afastamento><abonado>true</abonado><acidenteTrajeto>false</acidenteTrajeto><cids>E00</cids><codigoEmpresaFuncionario>297044</codigoEmpresaFuncionario><codigoFuncionario>1</codigoFuncionario><codigoMotivoAfastamento>35</codigoMotivoAfastamento><codigoSequencialLicenca>53938088</codigoSequencialLicenca><cpfFuncionario>06795882721</cpfFuncionario><dataFicha>05/10/2015</dataFicha><dataFimAfastamento>07/10/2015</dataFimAfastamento><dataInicioAfastamento>05/10/2015</dataInicioAfastamento><descricaoMotivo>3 DIAS.</descricaoMotivo><imprimirCid>false</imprimirCid><imprimirMotivo>false</imprimirMotivo><imprimirSolicitante>false</imprimirSolicitante><matriculaFuncionario>7777</matriculaFuncionario><tipoCid>DOENCA_RELACIONADOA_AO_TRABALHO</tipoCid><tipoDeAfastamento>11</tipoDeAfastamento></Afastamento></ns2:consultarLoteLicencasMedicasResponse></soap:Body></soap:Envelope></Resposta></Requisicao>
<Requisicao Chave="037c2757-a0f8-4c03-a4be-6bbfbdbe6280" Uri="http://vpc-1532-20132:1008/lg.com.br/svc/ServicoDeMovimentacao" DataHora="10:38:03.243"><Envio><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">lg.com.br/svc/ServicoDeMovimentacao/CadastreAfastamento</Action><h:LGAutenticacao xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="lg.com.br/svc/dto"><h:TokenSessao i:nil="true" /><h:tokenusuario>DADOS REMOVIDOS</h:tokenusuario></h:LGAutenticacao><h:LGContextoAmbiente xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="lg.com.br/svc/dto"><h:Ambiente>0</h:Ambiente><h:EnderecoHost i:nil="true" /><h:FuncaoEmExecucao i:nil="true" /><h:IdTenantSelecionado>0</h:IdTenantSelecionado><h:NomeHost i:nil="true" /><h:NomeTenantSelecionado i:nil="true" /></h:LGContextoAmbiente></s:Header><s:Body><CadastreAfastamento xmlns="lg.com.br/svc"><DadosAfastamento xmlns:d4p1="lg.com.br/svc/dto" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><d4p1:AcidenteDeTrajeto>false</d4p1:AcidenteDeTrajeto><d4p1:CID /><d4p1:CodigoDaEmpresa>1</d4p1:CodigoDaEmpresa><d4p1:CodigoDaSituacaoDeAfastamentoDoFuncionario>42</d4p1:CodigoDaSituacaoDeAfastamentoDoFuncionario><d4p1:DataDeInicioDoAfastamento>2015-10-15T00:00:00</d4p1:DataDeInicioDoAfastamento><d4p1:DataDeRetornoDoAfastamento>2015-10-16T00:00:00</d4p1:DataDeRetornoDoAfastamento><d4p1:DiasDeAuxilioDoenca i:nil="true" /><d4p1:DoencaRelacionadaAoTrabalho>false</d4p1:DoencaRelacionadaAoTrabalho><d4p1:MatriculaDoFuncionario>7780</d4p1:MatriculaDoFuncionario><d4p1:Observacao>1 DIA</d4p1:Observacao><d4p1:TipoDeAfastamentoRAIS>OUTROS</d4p1:TipoDeAfastamentoRAIS><d4p1:CalculeDiasAuxilioDoenca>false</d4p1:CalculeDiasAuxilioDoenca></DadosAfastamento></CadastreAfastamento></s:Body></s:Envelope></Envio></Requisicao>
<Requisicao Chave="037c2757-a0f8-4c03-a4be-6bbfbdbe6280" DataHora="10:38:24.354" TempoGasto="00:00:21.1618029"><Resposta><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header /><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring xml:lang="pt-BR">The creator of this fault did not specify a Reason.</faultstring><detail><ListaDeInconsistencias xmlns="lg.com.br/svc/dto" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Inconsistencias><Inconsistencia><Mensagem>Ocorrência de afastamento ja cadastrada.</Mensagem></Inconsistencia></Inconsistencias></ListaDeInconsistencias></detail></s:Fault></s:Body></s:Envelope></Resposta></Requisicao>
</Requisicoes>
drdamour commented 9 years ago

ditto:

Traceback (most recent call last): File "./sublimeplugin.py", line 362, in run File "./indentxml.py", line 49, in run File "./indentxml.py", line 96, in indent AttributeError: 'NoneType' object has no attribute 'replace' Traceback (most recent call last): File "./sublimeplugin.py", line 362, in run File "./indentxml.py", line 44, in run File "./indentxml.py", line 77, in indent File "./indentxml.py", line 96, in indent AttributeError: 'NoneType' object has no attribute 'replace'

on OSX Yosemite

YegorZdanovich commented 9 years ago

+1

4effo commented 9 years ago

In my case I have namespace what cases the issue: <foo><bar xmlns=""></bar></foo>

+1