pretty-xml icon indicating copy to clipboard operation
pretty-xml copied to clipboard

Fix for prevents line breaks in tags with no content

Open lucaohost opened this issue 6 years ago • 6 comments

lucaohost avatar Jan 22 '19 18:01 lucaohost

I don't know if this functionality already exists, but that code fix that for me

Example of the problem:

$xmlTest = "<?xml version='1.0'?>
<root><Cliente><codigoIbge>234234423</codigoIbge><sCodigoEmpresa>345345345</sCodigoEmpresa><sDescricaoEmpresa>Teste Innersite</sDescricaoEmpresa><sEnderecoEmpresa></sEnderecoEmpresa><sBairroEmpresa>Centro</sBairroEmpresa><sCEPEmpresa>20020-010</sCEPEmpresa><sMunicipioEmpresa>Rio de Janeiro</sMunicipioEmpresa><iNumeroEmpresa>00</iNumeroEmpresa><sCGCCPFEmpresa>6546.4684.16464</sCGCCPFEmpresa><sFoneEmpresa>(21) 22222-2222</sFoneEmpresa><sUfEmpresa>RJ</sUfEmpresa><sEmailEmpresa>[email protected]</sEmailEmpresa><sPaisEmpresa></sPaisEmpresa><sComplementoEmpresa>
00</sComplementoEmpresa><sTipoPessoaEmpresa>F</sTipoPessoaEmpresa><sTransportadora>0</sTransportadora><sDescricaoEmpresa2></sDescricaoEmpresa2><sDescricaoEmpresa1></";

echo "<textarea rows='35' style='width:600px;>".(new Formatter())->format($xmlTest)."</textarea>";

lucaohost avatar Jan 22 '19 18:01 lucaohost

Ideally there should be a test to illustrate the bad behaviour that this fixes

shanethehat avatar Jan 25 '19 12:01 shanethehat

Sorry, I put the test but not the demonstration.

selecao_526

selecao_528

Code:

$xmlTeste2 = "<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope'><SOAP-ENV:Body><ns1:catalogProductList><sessionId xsi:type='xsd:string'>1569b2058f34e29</sessionId><filters xsi:type='ns1:filters'><complex_filter SOAP-ENC:arrayType='ns1:complexFilter[1]'><item xsi:type='ns1:complexFilter'><key xsi:type='xsd:string'>sku</key><value xsi:type='ns1:associativeEntity'><key xsi:type='xsd:string'>in</key><Code></Code></value></item></complex_filter></filters><storeView xsi:nil='true'/></ns1:catalogProductList></SOAP-ENV:Body></SOAP-ENV:Envelope>";

echo "<textarea rows='35' style='width:600px;>".(new Formatter())->format($xmlTeste2)."</textarea>";

lucaohost avatar Jan 31 '19 12:01 lucaohost

@shanethehat

lucaohost avatar Jan 31 '19 12:01 lucaohost

The PR was not merged because it did not provide any test coverage for the change, and additionally has merge conflicts that need to be resolved.

Even if it was merged now, the CI and CD systems that used to build and publish it are very out of date. I've been out of the PHP world for so long that I wouldn't know where to begin with getting it up to date!

shanethehat avatar May 24 '24 14:05 shanethehat

ok, if you want to pass the ownership over to me, I would take care of the repo.

simonschaufi avatar May 24 '24 14:05 simonschaufi