Re: Extra linefeeds with groovy.xml.XmlUtil.serialize

"Nelson, Erick" <Erick.Nelson-NXabUB82sh5Wk0Htik3J/[email protected]>
Newsgroups gmane.comp.lang.groovy.user
Message-ID <BN0PR13MB4760E8B0A4BBC6E791501471E78F9@BN0PR13MB4760.namprd13.prod.outlook.com>
This appears to be a Java problem, not a Groovy problem,  and possibly an OpenJDK issue.
I’ve only been able to test this further on my Mac laptop as I cannot install different versions of Java.
Java 8 works as expected
I’ve tried Java 10, 11, 17, 18 and 19 and all appear to exhibit this behavior

From: Nelson, Erick <Erick.Nelson-NXabUB82sh5Wk0Htik3J/[email protected]>
Date: Tuesday, March 21, 2023 at 10:25 AM
To: users-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected] <users-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected]>
Subject: Extra linefeeds with groovy.xml.XmlUtil.serialize
I get extra line feeds on my mac when running identical code. Does anybody know why this would be?

On Linux… (expected output)

[tauser02@cfmips01ld0s work]$ groovy -v
Groovy Version: 4.0.10 JVM: 1.8.0_362 Vendor: Red Hat, Inc. OS: Linux
[tauser02@cfmips01ld0s work]$ cat test.groovy
String xml = $/<?xml version="1.0" encoding="UTF-8"?><root><elem1 attr1="value1" attr2="value2"/><elem2 attr1="value4" attr2="value4"/></root>/$
def doc = new groovy.xml.XmlParser().parseText(xml)
println groovy.xml.XmlUtil.serialize(doc)
[tauser02@cfmips01ld0s work]$ groovy test.groovy
<?xml version="1.0" encoding="UTF-8"?><root>
<elem1 attr1="value1" attr2="value2"/>
<elem2 attr1="value4" attr2="value4"/>
</root>



On my MAC…(note extra line feeds output)


en032339@C02CJMZ8MD6M ~ % groovy -v

Groovy Version: 4.0.10 JVM: 18.0.2.1 Vendor: Eclipse Adoptium OS: Mac OS X

en032339@C02CJMZ8MD6M ~ % cat test.groovy

String xml = $/<?xml version="1.0" encoding="UTF-8"?><root><elem1 attr1="value1" attr2="value2"/><elem2 attr1="value4" attr2="value4"/></root>/$

def doc = new groovy.xml.XmlParser().parseText(xml)

println groovy.xml.XmlUtil.serialize(doc)

en032339@C02CJMZ8MD6M ~ % groovy test.groovy

<?xml version="1.0" encoding="UTF-8"?><root>



  <elem1 attr1="value1" attr2="value2"/>



  <elem2 attr1="value4" attr2="value4"/>



</root>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.