You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's due to the namespace attribute: if a XML file contains a namespace attribute then each iteration of a pretty-print run adds a newline \n to the result file. I've adjusted the pretty-data/test/test_xml.js to show the issue:
var xml = '<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE foo SYSTEM "Foo.dtd"><a> <b>bbb</b> <!-- comment --><c/><d><soapenv:Envelope xmlns:soapenv="http://xxx" xmlns:xsd="http://yyy" xmlns:xsi="http://zzz"></soapenv> </d><e> <![CDATA[ <z></z> ]]></e><f><g></g></f></a>';
var pp_xml = require('../pretty-data').pd.xml(xml);
var pp2_xml = require('../pretty-data').pd.xml(pp_xml);
var pp3_xml = require('../pretty-data').pd.xml(pp2_xml);
console.log('\n==============================================================================\n');
console.log('\n/*------- Original XML string: -------*/\n\n' + xml + '\n');
console.log('\n/*------- Beautified XML -------------*/\n\n' + pp_xml + '\n');
console.log('\n/*------- Beautified twice XML -------------*/\n\n' + pp2_xml + '\n');
console.log('\n/*------- Beautified 3 times XML -------------*/\n\n' + pp3_xml + '\n');
console.log('\n===============================================================================\n');
It's due to the namespace attribute: if a XML file contains a namespace attribute then each iteration of a pretty-print run adds a newline
\n
to the result file. I've adjusted thepretty-data/test/test_xml.js
to show the issue:Result:
I expect that the 2nd and 3rd application of the pretty-print to this XML does not change the XML anymore. One application should be sufficient.
I've found this issue in version 0.40.0.
The text was updated successfully, but these errors were encountered: